看到n都1000位了, 肯定是规律了。。发现是3的倍数,就是B
#include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn = 1e3 + 5; char s[maxn]; int p[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}, sg[maxn], book[maxn]; //void get_sg() //{ // // cout << 1 << endl; // for(int i = 1; i <= 1000; i++) // { // memset(book, 0, sizeof(book)); // for(int j = 0; j < 11; j++) // { // if(i-p[j] >= 0) // { // book[sg[i-p[j]]] = 1; // } // } // for(int j = 0; book[j]; j++) // sg[i] = j+1; //这里是+1.。。 // } //} int main() { int t; cin >> t; while(t--) { scanf(" %s", s); int sum = 0; int len = strlen(s); for(int i = 0; i < len; i++) sum += s[i]-'0'; if(sum%3) printf("A\n"); else printf("B\n"); } return 0; }