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 |
wrong answer!!!!In Reply To:Re:救命啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Posted by:beijing2008 at 2006-05-10 00:57:17 #include<stdio.h> #include<iostream.h> #include<memory.h> #include<math.h> #include<string.h> int main() { int real[12],yi[12];char a[3][7],b[3][7],pan[3][6]; int i,j,num,k,p; scanf("%d",&num); while(num--) { memset(real,0,sizeof(real));memset(yi,1,sizeof(yi)); for(i=0;i<=2;i++) cin>>a[i]>>b[i]>>pan[i]; for(i=0;i<=2;i++) { p=strlen(a[i]); if(pan[i][0]=='e') { for(j=0;j<p;j++) { real[a[i][j]-65]=1; real[b[i][j]-65]=1; } } if(pan[i][0]=='u') { for(j=0;j<p;j++) { yi[b[i][j]-65]--; yi[a[i][j]-65]++; } } if(pan[i][0]=='d') { for(j=0;j<p;j++) { yi[b[i][j]-65]++; yi[a[i][j]-65]--; } } } for(i=0;i<=11;i++) { if(real[i]==1) yi[i]=0; } k=0; for(i=0;i<=11;i++) { if(abs(yi[i])>k) { k=abs(yi[i]); j=i; } } if(yi[j]<0) cout<<char('A'+j)<<" is the counterfeit coin and it is light."<<endl; else cout<<char('A'+j)<<" is the counterfeit coin and it is heavy."<<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