Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮帮忙吧(555)着道题我觉得应该不会太难,是不是我想的太简单了呢?交上去老是错的。谁能帮我看一下呢? 还有,这道题怎么才20个AC的??没人注意到它的存在吗? 附上我的程序: # include<iostream.h> class cow { public: cow(); void set(int); int get(int); void setformyself(); int get(); private: int pop[10000]; int pp; }; cow::cow() { for(int i=0;i<10000;i++) pop[i]=0; pp=0; } void cow::set(int a) { pop[a]=1; } int cow::get(int a) { return pop[a]; } void cow::setformyself() { pp++; } int cow::get() { return pp; } cow*cows; void main() { long n,m; long a,b,i,j; cin>>n>>m; cows=new cow[n]; for(i=0;i<m;i++) { cin>>a>>b; cows[a-1].set(b-1); for(j=0;j<n;j++) { if(cows[j].get(a-1)==1) cows[j].set(b-1); } } for(i=0;i<n;i++) cows[i].set(i); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(cows[j].get(i)) cows[i].setformyself(); } } for(i=0;i<n;i++) { if(cows[i].get()==n) cout<<i+1<<endl; } delete[]cows; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator