尼姆博弈HDU1907

HDU1907 http://acm.hdu.edu.cn/showproblem.php?pid=1907

尼姆博弈HDU1907

两种情况1.当全是1时,要看堆数的奇偶性

2.判断是奇异局势还是非奇异局势

代码:

 #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int m,n;
cin>>n;
while(n--)
{
int temp=;
int ans=;
int a[];
cin>>m;
for(int i=; i<m; i++)
{
cin>>a[i];
ans^=a[i];
if(a[i]>)
temp=;
} if(temp==)
{
if(m%==)
{
cout<<"John"<<endl; }
else
{
cout<<"Brother"<<endl; }
}
else
{ if(ans==)
{
cout<<"Brother"<<endl;
}
else
cout<<"John"<<endl; }
}
}
上一篇:sublime text 3如何安装插件


下一篇:matlab求曲线长度