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:不用再怀疑,WA的看这里了In Reply To:不用再怀疑,WA的看这里了 Posted by:ycdoit at 2011-03-16 15:04:54 #include<iostream> #include<cstring> #include<cmath> int num; char s[5][5][10]; char st[5][10]; int wei[20],value[20]; void input() { memset(wei,0,sizeof(wei)); memset(value,0,sizeof(value)); memset(s,0,sizeof(s)); for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) scanf("%s",s[i][j]); for(int i=1;i<=3;i++) for(int j=1;j<=2;j++) { if(strcmp(s[i][3],st[1])==0) { for(int k=0;k<=3;k++) value[s[i][j][k]-'A']=1; } if(strcmp(s[i][3],st[2])==0) { if(j==1) for(int k=0;k<=3;k++) wei[s[i][j][k]-'A']++; else for(int k=0;k<=3;k++) wei[s[i][j][k]-'A']--; } if(strcmp(s[i][3],st[3])==0) { if(j==1) for(int k=0;k<=3;k++) wei[s[i][j][k]-'A']--; else for(int k=0;k<=3;k++) wei[s[i][j][k]-'A']++; } } } void output() { int max=0,vis,weight=0; for(int i=0;i<=11;i++) { // printf("wei[%c]=%d value[%c]=%d\n",'A'+i,wei[i],'A'+i,value[i]); if(value[i]==0) if(abs(wei[i])>max) { max=abs(wei[i]); vis=i; if(wei[i]>0) weight=1; } } // system("pause"); printf("%c is the counterfeit coin and it is ",'A'+vis); if(weight) printf("heavy"); else printf("light"); printf(".\n"); } int main() { strcpy(st[1],"even"); strcpy(st[2],"up"); strcpy(st[3],"down"); scanf("%d",&num); while(num--) { input(); //system("pause"); output(); } //system("pause"); return 0; } 就是按这个思路走的,不知道哪里WA了,求解~~ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator