http://www.lydsy.com/JudgeOnline/problem.php?id=1022

反Nim游戏裸题.详见论文<组合游戏略述——浅谈SG游戏的若干拓展及变形>.

 

分析


 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 inline int read(int &x){x=0;int k=1;char c;for(c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')k=-1;for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';return x*=k;}
 4 
 5 int T,n,x,t,a;
 6 int main(){
 7     read(T);
 8     while(T--){
 9         read(n); x=t=0;
10         while(n--){
11             x^=read(a);
12             t+=a>1;
13         }
14         puts((!t&&!x)||(t&&x)?"John":"Brother");
15     }
16     return 0;
17 }
View Code

相关文章:

  • 2021-06-18
  • 2021-08-16
  • 2021-06-05
  • 2021-11-07
  • 2022-03-08
  • 2021-09-22
  • 2021-09-18
猜你喜欢
  • 2021-08-06
  • 2021-09-07
  • 2021-06-25
  • 2021-06-17
  • 2022-01-08
  • 2021-10-29
  • 2021-07-24
相关资源
相似解决方案