传送门

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,a,res=0;
int c=0,g=0;//¹Âµ¥¶Ñ¡¢³äÔ£¶Ñ
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a);
if(a>=2) c++;
else if(a==1) g++;
res^=a;
}
if(!res)//Òì»òΪ0£¬ÎªT̬
{
if(c>=2)//T2
printf("Brother\n");
else if(c==0)
printf("John\n");
}
else//S
{
if(g&1&&c==0)//S0
printf("Brother\n");
else if(c==1||c>=2)//S1,S2
printf("John\n");
}
}
return 0;
}

HDU 1907 John(取火柴博弈2)的更多相关文章

  1. HDU - 1907 John 反Nimm博弈

    思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1.  每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选 ...

  2. HDU 1907 John (Nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  3. hdu 1907 John (尼姆博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  4. POJ 3480 &amp; HDU 1907 John(尼姆博弈变形)

    题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...

  5. HDU 1907 John nim博弈变形

    John Problem Description   Little John is playing very funny game with his younger brother. There is ...

  6. HDU 1907 John(博弈)

    题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...

  7. hdu 1907 John&& hdu 2509 Be the Winner(基础nim博弈)

    Problem Description Little John is playing very funny game with his younger brother. There is one bi ...

  8. HDU 2509 Be the Winner(取火柴博弈2)

    传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...

  9. hdu 1907 (尼姆博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907 Problem Description Little John is playing very ...

随机推荐

  1. Android学习笔记(三)Android开发环境的搭建

    一.配置JAVA环境 二.配置Android开发环境 可以安装adt-bundle-windows,该压缩包一般自带Eclipse.或者安装Android Studio,要注意SDK的版本是否符合要求 ...

  2. jquery 图片遮罩 坠落遮挡效果

    <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...

  3. Chapter 21_5.1 URL编码

    URL编码是http所使用的一种编码方式,用于在一个URL中传送各种参数.该编码方式会将特殊字符("=","&","+")编码为&q ...

  4. python reduce使用实例

    通过一个简单的算法来了解reduce的巧用. 构建函数persistence(n),如果n>9,则返回0.否则继续根据n的权重来分解n,如n=999,则分解为9,9,9.那么将9*9*9=729 ...

  5. U3D音频系统

    一.基本信息 1.支持的声音格式 WAV OGG MP3 AIFF MOD S3M xm IT    导入以后,unity会选择的压缩方式: WAV:无损,音质好,文件大,适用于较短文件 OGG.MP ...

  6. 记录下 js各种证件的正则验证

    身份证 /(^\d{15}$)|(^\d{17}([0-9]|X)$)/    护照 /^[a-zA-Z0-9]{3,21}$/   /^(P\d{7})|(G\d{8})$/    军官证或士兵证 ...

  7. android应用编译失败 ResXMLTree_node size 类错误,以及 android studio 项目内搜索

    今天很郁闷,又遇到个很让人崩溃的问题: ResXMLTree_node size 0 is smaller than header size 0x45. 类似这样的错误,提示中看不出任何有用的内容,网 ...

  8. HDU 5887 Herbs Gathering

    背包,$map$,优化. 和普通背包一样,$map$加一个$erase$优化一下就可以跑的很快了. #pragma comment(linker, "/STACK:1024000000,10 ...

  9. USACO 3.2 Contact

    ContactIOI'98 The cows have developed a new interest in scanning the universe outside their farm wit ...

  10. .Net中jQuery.ajax()调用asp.net后台方法 总结

    利用JQuery的$.ajax()调用.Net后台方法有多种方式, 不多说了  直接上代码 前台代码 <script type="text/javascript"> $ ...