POJ1013
逻辑推理诶,如果按照人类的思维推断,那好麻烦啊,唉计算机就是傻叉。
所以竟然可以通过数值表示疑似假币的程度。于是我也不知道为什么这就是正解。
此外,发现了G++和C++竟然也不一样,如果是G++,没有#include <cstdlib>调用abs 就不能编译通过,不过fabs还是在cmath库中的。奇怪,所以还是要多打几个库保险。。。
我滴代码能力还是弱爆了。。
/********************************* AC 2015-06-03 *********************************/ #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> using namespace std; int main() { int n; scanf("%d",&n); while(n--){ char str1[12], str2[12], str3[12]; bool zero[12]; int fake[12]; memset(zero,0,sizeof(zero)); memset(fake,0,sizeof(fake)); for(int i=1;i<=3;i++){ scanf("%s%s%s",str1,str2,str3); for(int j=0;j<strlen(str1);j++){ int c=str1[j]-'A'; switch(str3[0]){ case 'e': zero[c]=true; break; case 'u': fake[c]++; break; case 'd': fake[c]--; break; } } for(int j=0;j<strlen(str2);j++){ int c=str2[j]-'A'; switch(str3[0]){ case 'e': zero[c]=true; break; case 'u': fake[c]--; break; case 'd': fake[c]++; break; } } } int max=0,ans=0; for(int j=0;j<12;j++){ if(zero[j])continue; if(abs(fake[j])>max){max=abs(fake[j]);ans=j;} } cout<<char(ans+'A'); if(fake[ans]<0)cout<<" is the counterfeit coin and it is light."<<endl; else cout<<" is the counterfeit coin and it is heavy."<<endl; } return 0; }
当有那么一天,你相信你可以做到的时候,那你就真的能够做到!
路在脚下

浙公网安备 33010602011771号