| ||||||||||
| 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>
#include <cstring>
using namespace std;
int main()
{int n,g[12][3],i,la,lb,k;
string a,b,c;
cin>>n;
while (n--)
{for (i=0;i<12;i++)
for (k=0;k<3;k++)
g[i][k]=-2;
for (i=0;i<=2;i++)
{cin>>a>>b>>c;
if (c=="even") {lb=la=a.length();
while (la) g[a[--la]-65][i]=0;
while (lb) g[b[--lb]-65][i]=0;}
else {if (c=="down") {c=a;a=b;b=c;}
lb=la=a.length();
while (la) g[a[--la]-65][i]=1;
while (lb) g[b[--lb]-65][i]=-1;
for (k=0;k<12;k++) if (g[k][i]==-2) g[k][i]=0;}
}
for (k=0;k<12;k++)
if (g[k][0]*g[k][1]*g[k][2]) if (g[k][1]*g[k][2]!=-1 && g[k][1]*g[k][0]!=-1 && g[k][2]*g[k][0]!=-1)
{cout<<char(k+65)<<" is the counterfeit coin and it is ";
if (g[k][0]==-1 || g[k][1]==-1 ||g[k][2]==-1) cout<<"light."<<endl;
else cout<<"heavy."<<endl;
break;}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator