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 |
路过的都来帮我找找错 谢谢!结果是WA的代码 #include<iostream> using namespace std; int mycompare(const void *elem1,const void *elem2) { return *(int *)elem2-*(int *)elem1; } int main() { int t,r,i,m,sum,edge,accouts; int length[30],k; bool judge[5],flag; cin>>t; for(r=0;r<t;r++) { sum=0; memset(judge,false,sizeof(judge)); cin>>m; for(i=0;i<m;i++) { cin>>length[i]; sum+=length[i]; } qsort(length,m,sizeof(int),mycompare); if(sum%4==0) { edge=sum/4; if(length[0]<=edge) { accouts=4; while(accouts>0) { flag=false; k=0; for(i=0;i<m;i++) { k+=length[i]; if(k>edge) { k-=length[i]; continue; } if(k<edge) { length[i]=0; continue; } if(k==edge) { judge[accouts]=true; length[i]=0; break; } } accouts--; } if(judge[1] && judge[2] && judge[3] && judge[4]) cout<<"yes"<<endl; else cout<<"no"<<endl; } else cout<<"no"<<endl; } else cout<<"no"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator