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. 【北京/上海/南京】【部门直推】【可查询】【实习&社招】字节跳动数据平台前端内推

    [北京/上海/南京][部门直推][可查询][实习&社招]字节跳动数据平台前端内推 重要信息,写在前面  [投递邮箱]chengxinsong@bytedance.com [微信扫码] 2019 ...

  2. C#winfrom文件下载到本地

    string remoteUri = System.IO.Path.GetDirectoryName(url); string fileName = System.IO.Path.GetFileNam ...

  3. nyoj 55-懒省事的小明(priority_queue)

    55-懒省事的小明 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:8 submit:62 题目描述:       小明很想吃果子,正好果园果子熟了. ...

  4. 领扣(LeetCode)设计哈希映射 个人题解

    不使用任何内建的哈希表库设计一个哈希映射 具体地说,你的设计应该包含以下的功能 put(key, value):向哈希映射中插入(键,值)的数值对.如果键对应的值已经存在,更新这个值. get(key ...

  5. markdown总结 (webstrom快捷键)

    # 在HbuilderX中写markdown(WebStrom快捷键配置)0. 一些快捷键和鼠标操作:1. ctrl+shift+↑  当前行或者选中的块整体向上移动  ↓同理2. 向两侧扩大选择:A ...

  6. 实现 Redis 协议解析器

    本文是 <用 Golang 实现一个 Redis>系列文章第二篇,本文将分别介绍Redis 通信协议 以及 协议解析器 的实现,若您对协议有所了解可以直接阅读协议解析器部分. Redis ...

  7. Java描述设计模式(22):策略模式

    本文源码:GitHub·点这里 || GitEE·点这里 一.生活场景 每年双十一,各大电商平台会推出不同的满减策略,当用户的消费金额满一定额度后,会进行减去一定的优惠额度,从而来一波清仓甩卖,使用策 ...

  8. 消除router-link 的下划线问题

    <div class="small-size"> <router-link to="/About"> <img src=" ...

  9. 【翻译】全球用尽IPv4的一点思考

    作者:Dimple 公众号:奔跑吧攻城狮 简介:专属于Java和Android开发,和你聊聊职场话题,一同展望未来 作为小小号主的我表示很无力啊,这几天,天天都是热点.前有网易员工勇敢发声维护自己的利 ...

  10. Hadoop运行模式

    Hadoop运行模式 (1)本地模式(默认模式): 不需要启用单独进程,直接可以运行,测试和开发时使用. 即在一台机器上进行操作,仅为单机版. 本地运行Hadoop官方MapReduce案例 操作命令 ...