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 |
CODE#include <cstdio> #define N 1000 char ch1[3][N],ch2[3][N],ch3[3][N]; bool check(int a,int v) { char A=a+'A'; for(int i=0;i<3;++i) { int sum1=0,sum2=0; for(int j=0;ch1[i][j];++j) sum1+=(ch1[i][j]==A ? v : 1 ); for(int j=0;ch2[i][j];++j) sum2+=(ch2[i][j]==A ? v : 1 ); if(ch3[i][0]=='e' && sum1!=sum2) return 0; if(ch3[i][0]=='u' && sum1<=sum2) return 0; if(ch3[i][0]=='d' && sum1>=sum2) return 0; } return 1; } void work() { for(int i=0;i<3;++i) scanf("%s%s%s",ch1[i],ch2[i],ch3[i]); for(int i=0;i<26;++i) { if(check(i,0)) printf("%c is the counterfeit coin and it is light. \n",char(i+'A')); if(check(i,2)) printf("%c is the counterfeit coin and it is heavy. \n",char(i+'A')); } } int main() { int n; scanf("%d",&n); while(n--) work(); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator