Description

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.

 

Input

The 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

 

Output

Output 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
 

Source

Southeastern Europe 2007

依旧是anti-nim

AC记录喜+1

 /*by SilverN*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
int s;
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
bool flag=;
s=;
int i,j;
int a;
for(i=;i<=n;i++){
scanf("%d",&a);
s^=a;
if(a>)flag=;
}
if(flag){
if(s==)printf("Brother\n");
else printf("John\n");
}
else
if(n&)printf("Brother\n");
else printf("John\n"); }
return ;
}

HDU1907 John的更多相关文章

  1. hdu1907 John 博弈

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

  2. 尼姆博弈HDU1907

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

  3. John the ripper使用教程

    破解Linux的用户密码:John [跨平台的密码解密工具] root@only:~# unshadow /etc/passwd /etc/shadow > ~/file_to_crack ro ...

  4. *HDU1907 博弈

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

  5. HDU 1907 John nim博弈变形

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

  6. Js-字符串截取substring,分割split,指标indexOf,拼接John

    函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组例子: var theString=”jpg|bmp|gif|ico|png”; var arr=theString.spli ...

  7. John the Ripper

    John the RipperJohn the Ripper(简称John)是一款著名的密码破解工具.它主要针对各种Hash加密的密文.它不同于Rainbow Table方式.它采用实时运算的方式和密 ...

  8. POJ 3683 Priest John's Busiest Day(2-SAT 并输出解)

    Description John is the only priest in his town. September 1st is the John's busiest day in a year b ...

  9. BZOJ1022 [SHOI2008]小约翰的游戏John

    Description 小约翰经常和他的哥哥玩一个非常有趣的游戏:桌子上有n堆石子,小约翰和他的哥哥轮流取石子,每个人取 的时候,可以随意选择一堆石子,在这堆石子中取走任意多的石子,但不能一粒石子也不 ...

随机推荐

  1. AMAP

    ViewController.m #import "ViewController.h" //地图显示需要的头文件 #import <MAMapKit/MAMapKit.h&g ...

  2. 20Mybatis_订单商品数据模型_一对一查询——resultType和resultMap两种方式以及两种方式的总结

    上一篇文章分析了数据模型,这篇文章就给出一个需求,这个需求是一对一查询,并完成这个需求. ------------------------------------------------------- ...

  3. 由源码密码文件转转化成keystore

      1.android 源码目录build\target\product\security 取platform.pk8 platform.x509.pem放到一个目录下 E:\sign\convert ...

  4. 使用地址栏访问CXF Webservice写法

    /* * 通过url调用 * http://localhost:8080/EFP/webService/TestWebservice/testOut/arg0/liuyx */ http://loca ...

  5. SQLServer如何删除字段中的某个字符串,或者替换为空格?

    sql="update Table set 字段=REPLACE ( 字段,'123' , ' ') where XXX条件"把字段中123替换为空格

  6. H5实现拍照并上传

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

  7. IOS开发之—— ShareSDK的使用

    官方下载ShareSDK iOS:http://sharesdk.cn/ ShareSDK社会化分享 包含“社会化分享组件”“社会化登录组件”“第三方评论和赞”三大模块,并有详尽的数据统计后台,助力移 ...

  8. VS2010下配置使用OpenGL的glut库

    我已在我机上测试成功,机装VS2010! 在win7(windows7 ultimate SP1)下成功安装VS2010(Visual Studio 2010 ultimate x86). 下载glu ...

  9. 关于UITextView / String的尺寸

    关于UITextView以及String的尺寸动态获取 iOS7开始,UITextView设置text后不会立即反映到contentSize属性,而是在父容器layoutSubviews时进行cont ...

  10. [MCSM]Exponential family: 指数分布族

    Exponential family(指数分布族)是一个经常出现的概念,但是对其定义并不是特别的清晰,今天好好看了看WIKI上的内容,有了一个大致的了解,先和大家分享下.本文基本是WIKI上部分内容的 ...