HDU 1907 (博弈) John

参见上一篇博客,里面有分析和结论。

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5     int T; scanf("%d", &T);
 6     while(T--)
 7     {
 8         int n, a, c = 0, xorsum = 0;//c为充裕堆的个数
 9         scanf("%d", &n);
10 
11         while(n--) { scanf("%d", &a); xorsum ^= a; if(a > 1) c++; }
12         if((!xorsum && c >= 2) || (xorsum && !c)) puts("Brother");//T2和S0状态必败
13         else puts("John");//T0和S1和S2状态必胜
14     }
15 
16     return 0;
17 }
代码君

 

posted @ 2015-04-06 21:36  AOQNRMGYXLMV  阅读(215)  评论(0编辑  收藏  举报