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 |
实在没辙了。我先是用排除法做,WA,后来没办法改用暴力,还是WA,请高手指教。#include <iostream> #include <string.h> using namespace std; int Flag[12]; int Up[8][8],Upl; int main() { char Buffer[8],Buffer1[10]; int n,n1; cin>>n; for (n1=0;n1<n;n1++) { int i,j,k,l; for (i=0;i<12;i++) Flag[i]=0; Upl=0; for (i=0;i<3;i++) { for (j=0;j<8;j++) { cin>>Buffer[j]; while (Buffer[j]<'A' || Buffer[j]>'L') cin>>Buffer[j]; } for (j=0;j<2;j++) { cin>>Buffer1[j]; while (Buffer1[j]<'a' || Buffer1[j]>'z') cin>>Buffer1[j]; } Buffer1[2]=Buffer1[4]=0; if (Buffer1[0]!='u') for (j=0;j<2;j++) { cin>>Buffer1[j+2]; while (Buffer1[j+2]<'a' || Buffer1[j+2]>'z') cin>>Buffer1[j+2]; } if (!strcmp(Buffer1,"even")) { for (j=0;j<8;j++) { Flag[Buffer[j]-'A']=1; } } else if(!strcmp(Buffer1,"up")) { for (j=0;j<8;j++)Up[Upl][j]=Buffer[j]-'A'; Upl++; } else // if (!strcmp(Buffer1,"down")) { for (j=0;j<4;j++) { Up[Upl][j]=Buffer[j+4]-'A'; Up[Upl][j+4]=Buffer[j]-'A'; } Upl++; } } for (i=0;i<12;i++) if (Flag[i]!=1) { l=1; for (j=0;j<Upl;j++) { for (k=0;k<4;k++) if (Up[j][k]==i) break; if (k==4) l=0; } if (l) { cout<<(char)(i+'A')<<" is the counterfeit coin and it is heavy."<<endl; } l=1; for (j=0;j<Upl;j++) { for (k=4;k<8;k++) if (Up[j][k]==i) break; if (k==8) l=0; } if (l) { cout<<(char)(i+'A')<<" is the counterfeit coin and it is light."<<endl; } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator