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 |
Re:暴力穷举可以通过呀^_^为啥我的不行呢???我觉的我想的很清楚啊In Reply To:暴力穷举可以通过呀^_^ Posted by:jane332470 at 2005-04-03 12:41:10 /********************************** 1013acm by yex 4 18 conterfeit coin ***********************************/ #include<iostream.h> #include<string.h> void main() { int turn; int sum; char left[3][10];int ileft[3][10]; char right[3][10];int iright[3][10]; char result[3][7];int iresult[3]; int weight[12]={0}; int length[3]={0}; cin>>turn ; while(turn--) { for(int count=0;count<12;count++) { weight[count]=0; } sum=0; length[0]=length[1]=length[2]=0; for(count=0;count<3;count++) { cin>>left[count]>>right[count]>>result[count]; int count2; count2=0; while(left[count][count2]!='\0') { length[count]++; count2++; } int count1; for(count1=0;count1<length[count];count1++) { ileft[count][count1]=left[count][count1]-'A'; iright[count][count1]=right[count][count1]-'A'; } if(strcmp(result[count],"dowm")==0) iresult[count]=-1; if(strcmp(result[count],"even")==0) iresult[count]=0; if(strcmp(result[count],"up")==0) iresult[count]=1; } for(count=0;count<12;count++) { weight[count]=1; for( int count1=0;count1<3;count1++) { sum=0; for(int count2=0;count2<length[count1];count2++) { sum+=weight[ileft[count1][count2]]-weight[iright[count1][count2]]; } if(sum!=iresult[count1]) { weight[count]=0;break;} } if(count1==3) { cout<<char('A'+count)<<" is the counterfeit coin and it is "<<"heavy."<<endl; weight[count]=0;break; } weight[count]=-1; for( count1=0;count1<3;count1++) { sum=0; for(int count2=0;count2<length[count1];count2++) { sum+=weight[ileft[count1][count2]]-weight[iright[count1][count2]]; } if(sum!=iresult[count1]) {weight[count]=0;break;} } if(count1==3) { cout<<char('A'+count)<<" is the counterfeit coin and it is "<<"light."<<endl; weight[count]=0;break ; } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator