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 |
一个简单的思路枚举每个球为假,再枚举其是轻是重,带入三个等式或不等式判断,全部符合说明这种情况正确 附代码 #include<iostream> #include<string> using namespace std; int main() {int n,i,j,x,y,s[15],k,ll,an,l; string a[4],b[4],c[4],x1="even", x2="up",x3="down"; char u; cin>>n; for (ll=1;ll<=n;ll++) { for (i=1;i<=3;i++) cin>>a[i]>>b[i]>>c[i]; for (i=1;i<=12;i++) for (l=1;l<=2;l++) {for (j=1;j<=12;j++) s[j]=1; s[i]=0; an=0; for (j=1;j<=3;j++) {x=0; for (k=0;k<=a[j].size()-1;k++) x=x+s[a[j][k]-'A'+1]; y=0; for (k=0;k<=b[j].size()-1;k++) y=y+s[b[j][k]-'A'+1]; if (c[j]==x1) if (x!=y){an=1;break;} if ((c[j]==x2)and(l==1)) if (x<=y){an=1;break;} if ((c[j]==x2)and(l==2)) if (x>=y){an=1;break;} if ((c[j]==x3)and(l==1)) if (x>=y){an=1;break;} if ((c[j]==x3)and(l==2)) if (x<=y){an=1;break;} } u='A'+i-1; if (an==0) {cout<<u<<" is the counterfeit coin and it is "; if (l==1) cout<<"light.";else cout<<"heavy.";cout<<endl;break;} } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator