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 |
1AC感谢前辈们的disguss……#include <iostream> #include <cmath> using namespace std; char l[3][7],r[3][7],a[3][7]; int b[15]; int i,n,k,j,t; int main() { cin>>t; for(k=0;k<t;k++){ memset(b,0,sizeof(b)); for(i=0;i<3;i++) cin>>l[i]>>r[i]>>a[i]; for(i=0;i<3;i++){ n=strlen(l[i]); if(a[i][0]=='e') for(j=0;j<n;j++){ b[l[i][j]-'A']=100; b[r[i][j]-'A']=100; } } for(i=0;i<3;i++){ n=strlen(l[i]); for(j=0;j<n;j++){ if(a[i][0]=='u'){ if(b[l[i][j]-'A']!=100) b[l[i][j]-'A']++; if(b[r[i][j]-'A']!=100) b[r[i][j]-'A']--; } if(a[i][0]=='d'){ if(b[r[i][j]-'A']!=100) b[r[i][j]-'A']++; if(b[l[i][j]-'A']!=100) b[l[i][j]-'A']--; } } } int m=0; int z=0; for(i=0;i<15;i++){ if(b[i]==100) continue; if(abs(b[i])>m){ m=abs(b[i]); z=i; } } if(b[z]>0) cout<<char('A'+z)<<" is the counterfeit coin and it is heavy."<<endl; else cout<<char('A'+z)<<" is the counterfeit coin and it is light."<<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