Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so on. Please note that each player has to eat at least one M&M during his turn. If John (or his brother) will eat the last M&M from the box he will be considered as a looser and he will have to buy a new candy box.

Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.

InputThe first line of input will contain a single integer T – the number of test cases. Next T pairs of lines will describe tests in a following format. The first line of each test will contain an integer N – the amount of different M&M colors in a box. Next line will contain N integers Ai, separated by spaces – amount of M&Ms of i-th color.

Constraints: 
1 <= T <= 474, 
1 <= N <= 47, 
1 <= Ai <= 4747

OutputOutput T lines each of them containing information about game winner. Print “John” if John will win the game or “Brother” in other case.

Sample Input

2
3
3 5 1
1
1

Sample Output

John
Brother
题解:考虑多个1的情况
参考代码:
 #include<bits/stdc++.h>
using namespace std;
int T,n,ans,x,num; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);ans=num=;
for(int i=;i<=n;++i) {scanf("%d",&x);ans^=x;if(x>) num++;}
if((!ans&&num>) || (ans&&!num)) puts("Brother");
else puts("John");
} return ;
}

HDU1907 Jhon的更多相关文章

  1. 尼姆博弈HDU1907

    HDU1907 http://acm.hdu.edu.cn/showproblem.php?pid=1907 两种情况1.当全是1时,要看堆数的奇偶性 2.判断是奇异局势还是非奇异局势 代码: #in ...

  2. *HDU1907 博弈

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

  3. HDU1907 John

    Description Little John is playing very funny game with his younger brother. There is one big box fi ...

  4. hdu1907(anti-sg入门)

    改变了下规则,现在变成了最后拿的人输. 如果对于单纯的nim的话,只需要判断每堆都是1个石子的特殊情况. 因为如果存在有大于1个石子的堆话,类似于nim的取法,处于必胜状态的一方只需要在 对方取完后只 ...

  5. hdu1907 John 博弈

    Little John is playing very funny game with his younger brother. There is one big box filled with M& ...

  6. HDU1907(尼姆博弈)

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

  7. hdu1907 尼姆博弈

    尼姆博弈的性质. 最后一个取输.若a1^a2^a3...^a4=0表示利他态T,不然为利己态S.充裕堆:1个堆里的个数大于2.T2表示充裕堆大于等于2,T1表示充裕堆大于等于1,T0表示无充裕堆.S2 ...

  8. sort()基础知识总结+超简短的英文名排序写法

    结合前些天学的箭头函数我想到一种非常简短的sort排序写法:(这可能是最短的英文名排序方法了) 贴出来大家一起探讨一下: [4,1,2,32].sort((x,y)=>x>y); //[1 ...

  9. React学习笔记-8-属性和状态详解

    属性的含义和用法props=properties 英文中属性的意思.属性不可以修改,也就是属性不可以由组件进行修改,组件的属性是由父组件传递过来的,相当于组件在出生的时候带的.用法第一种:直接在调用组 ...

随机推荐

  1. 美团店铺数据抓取 token解析与生成

    美团.点评网的token都是用一套加密算法,实际上就是个gzip压缩算法.加密了2次,第一次是加密了个sign值,然后把sign值带进去参数中进行第二次加密,最后得出token 分析请求 打开上海美食 ...

  2. linux环境中,两个不同网段的机器互通

    linux环境中,两个不同网段的机器互通   人评论3690人阅读2019-11-18 14:50:21   环境如下:   host1 单网卡 eth0 172.24.100.15/16   hos ...

  3. centos6官网镜像dvd1和dvd2的解释

  4. ASP.NET Core 1.0: API的输入参数

    Web API是需要接受参数的,譬如,通常用于创建数据的POST method需要接受输入数据,而用于GET method也需要接受一些可选参数,譬如:为了性能起见,控制返回数据的数量是至关重要的. ...

  5. Thrift总结(四)Thrift实现双向通信

    前面介绍过 Thrift 安装和使用,介绍了Thrift服务的发布和客户端调用,可以查看我之前的文章:https://www.cnblogs.com/zhangweizhong/category/10 ...

  6. Flsk&pyecharts 动态数据可视化

    1:数据源 Hollywood Movie Dataset: 好莱坞2006-2011数据集  实验目的: 实现 统计2006-2011的数据综合统计情况,进行数据可视化 gitee地址: https ...

  7. 搭建Nginx正向代理服务

    需求背景: 前段时间公司因为业务需求需要部署一个正向代理,需要内网服务通过正向代理访问到外网移动端厂商域名通道等效果,之前一直用nginx做四层或者七层的反向代理,正向代理还是第一次配置,配置的过程也 ...

  8. django_4数据库2——表外键

    表关系: many to one many to many one to one many to one 记录是如何创建出来的?      先创建one,在在创建many,创建时加入ForeignKe ...

  9. Mac usr/bin 目录 权限问题

    Mac进行 usr/bin 目录下修改权限问题,operation not permitted 一般情况下我们在使用mac系统过程中下载一些文件.新建一些项目之后,这些文件都会默认是只读状态,这时我们 ...

  10. 报错:尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,将出现此问题。

    问题: 在写windows服务时,发布后日志报错:尝试加载 Oracle 客户端库时引发 BadImageFormatException.如果在安装 32 位 Oracle 客户端组件的情况下以 64 ...