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的原因?各种情况我都试过了,两边不必都放4个砝码,但就是WA?请指点。In Reply To:这题太贱了,第一次见这样的题目,居然还要去判断可能性最大的一个,害的我WA了N次 Posted by:windbells at 2004-07-18 18:45:23 #include <stdio.h> main() { int t,tt; char c[3][8],tmp; int a[12]; int i,j,k,ok,n; int b[8],bb,bk; scanf("%d",&tt); getchar(); for(t=0;t<tt;t++) { for(i=0;i<12;i++) a[i]=9; for(k=0;k<3;k++) { for(i=0;i<4;i++) { c[0][i]=getchar(); if(c[0][i]==' ') {break;} } if(i==4) getchar(); for(;i<4;i++) c[0][i]=' '; for(i=0;i<4;i++) { c[0][i+4]=getchar(); if(c[0][i+4]==' ') {break;} } if(i==4) getchar(); for(;i<4;i++) c[0][i+4]=' '; tmp=getchar(); if(tmp=='e') {ok=0; getchar(); getchar(); getchar(); getchar();} else if(tmp=='u') {ok=1; getchar(); getchar();} else if(tmp=='d') {ok=-1; getchar(); getchar(); getchar(); getchar();} else break; if(ok==0) { for(i=0;i<8;i++) { n=(int)(c[0][i]-'A'); if(n>=0) a[n]=0; } } else if(ok==1) { bb=0; for(i=0;i<8;i++) { n=(int)(c[0][i]-'A'); if(n>=0) if(a[n]==9) {if(i<4) a[n]=1; else a[n]=-1; b[bb]=n; bb++;} else if(a[n]==1) {if(i<4) a[n]=1; else a[n]=0; b[bb]=n; bb++;} else if(a[n]==-1) {if(i<4) a[n]=0; else a[n]=-1; b[bb]=n; bb++;} } for(i=0;i<12;i++) { bk=0; for(j=0;j<bb;j++) if(i==b[j]) bk=1; if(bk==0) { a[i]=0; } } } else if(ok==-1) { bb=0; for(i=0;i<8;i++) { n=(int)(c[0][i]-'A'); if(n>=0) if(a[n]==9) {if(i<4) a[n]=-1; else a[n]=1; b[bb]=n; bb++;} else if(a[n]==-1) {if(i<4) a[n]=-1; else a[n]=0; b[bb]=n; bb++;} else if(a[n]==1) {if(i<4) a[n]=0; else a[n]=1; b[bb]=n; bb++;} } for(i=0;i<12;i++) { bk=0; for(j=0;j<bb;j++) if(i==b[j]) bk=1; if(bk==0) { a[i]=0; } } } } for(i=0;i<12;i++) if(a[i]!=0) break; if(a[i]>0) printf("%c is the counterfeit coin and it is heavy.\n",i+'A'); else printf("%c is the counterfeit coin and it is light.\n",i+'A'); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator