hdu_1907:John(Nim变形)

题目链接

仍是取石子,不过取到最后一个的败

参考链接:http://www.voidcn.com/blog/liwen_7/article/p-3341825.html

简单一句话就是T2 S0必败

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     int T;scanf("%d",&T);
 7     while(T--)
 8     {
 9         int n;scanf("%d",&n);
10         int ans=0;
11         bool flag=false;
12         while(n--)
13         {
14             int t;
15             scanf("%d",&t);
16             ans^=t;
17             if(t>1) flag=true;
18         }
19         if(flag&&!ans || !flag&&ans)
20             puts("Brother");
21         else
22             puts("John");
23     }
24 }
View Code
原文地址:https://www.cnblogs.com/Just--Do--It/p/6421447.html