# John

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 4537    Accepted Submission(s): 2602

Problem 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

``` //S0，T2必败，其他情况必胜
#include<iostream>
using namespace std;
int main()
{
int t,n,x;
cin>>t;
while(t--)
{
cin>>n;
int ans=,flag=;
for(int i=;i<n;i++)
{
cin>>x;
ans=(ans^x);
if(x>) flag++;
}
if(!flag)
{
if(n&) cout<<"Brother\n";
else cout<<"John\n";
}
else
{
if(ans==&&flag>=) cout<<"Brother\n";
else cout<<"John\n";
}

}
return ;
}```

## *HDU1907 博弈的更多相关文章

1. 尼姆博弈HDU1907

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

2. hdu1907 John 博弈

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

3. HDU1907（尼姆博弈）

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

4. hdu1907 尼姆博弈

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

5. hdu----(1849)Rabbit and Grass（简单的尼姆博弈）

Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

6. HDU 5754 Life Winner Bo 组合博弈

Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard gam ...

7. HDU 2509 Nim博弈变形

1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

8. HDU 1907 Nim博弈变形

1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

9. 51nod1072(wythoff 博弈)

题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1072 题意: 中文题诶~ 思路: 博弈套路是有的, 找np局 ...

## 随机推荐

1. myeclipse下安装svn

在网上查了一下,安装的方法有几种,这里给大家推荐一种快速安装的方法. //第一步 : 下载 site-1.6.5.zip //===================================== ...

2. centos7和windows7双系统安装

前些天安装了双系统(centos7+win7),其实网上关于这类的教程很多,这篇日志也只是针对本人安装过程中遇到的一些问题进行说明.我是按照先安装win7再安装centos7的顺序. 1.关于分区: ...

3. JavaScript学习笔记2-数组对象

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

4. C# 得到本机局域网IP地址

C#获取本机IP搜集整理7种方法:http://blog.csdn.net/frombegintoend/article/details/7713097 使用IPHostEntry获取本机局域网地址 ...

5. js 中采用词法作用域

所谓的 词法( 代码 )作用域, 就是代码在编写过程中体现出来的作用范围. 代码一旦写好, 不用执行, 作用范围就已经确定好了. 这个就是所谓词法作用域. 在 js 中词法作用域规则: 1.函数允许访 ...

6. Problem C: 是否回文数？

Description 定义Data类,有一个int类型的属性.定义其构造函数.setValue函数和isPalindrome函数,其中setValue函数用于设置属性值,isPalindrome用于 ...

7. BZOJ 4196 软件包管理器

树链剖分 建树之后,安装软件就是让跟节点到安装的节点路径所有点权+1,卸载软件就是让一个节点和他的子数-1 要求变化数量的话直接求和相减就行啦(绝对值) 注意一点,一开始的lazyatag应该是-1, ...

8. CentOS安装.NET CORE

Add the dotnet product feed sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo ...

9. Java 读取文件的内容

Java 读取文件的内容 1) CLASS_NAME: 换成自己真实的类名 2) /page/test.json: 换成自己真实的page 3) FileUtils: 来自于org.apache.co ...

10. C#-MVC开发微信应用(7)--在管理系统中同步微信用户分组信息

在前面几篇文章中,逐步从原有微信的API封装的基础上过渡到微信应用平台管理系统里面,逐步介绍管理系统中的微信数据的界面设计,以及相关的处理操作过程的逻辑和代码.希望从一个更高的层次介绍微信的开发. 在 ...