传送门:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1068
Solution
继续打表找规律。。。
发现n为3的倍数时必输。
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int T,n,sum; char s[1005]; int main(){ for (int i=1;i<=1000;i++) for (int j=0;(1<<j)<=i;j++) f[i]=!f[i-(1<<j)]||f[i]; for (int i=1;i<=20;i++) printf("%d ",f[i]);*/ scanf("%d",&T); while (T--){ scanf("%s",s+1); n=strlen(s+1); sum=0; for (int i=1;i<=n;i++) sum+=s[i]-'0'; if (sum%3) putchar('A'); else putchar('B'); putchar('\n'); } }
|