John

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

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
Recommend
lcy
简单的nim博弈.....(但是要注意全部为1的情况)....那是就不是nim博弈啦!!
代码:我想说的是,要把名字看清楚,开始将Johe---打错了...打成jone  ,哎!!,尼玛,那叫一个错呀!!
//http://acm.hdu.edu.cn/showproblem.php?pid=1907
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std; int main()
{
int t,n,i,x;
bool flag ;
cin>>t;
while(t--)
{
scanf("%d",&n);
vector<int>num(n+);
x=,flag=false;
for(i=;i<n;i++)
{
scanf("%d",&num[i]);
x^=num[i];
}
for(i=;i<n;i++)
{
if(num[i]>)
{
flag=true;
break;
}
}
if(flag)
{
if(x) puts("John");
else puts("Brother");
}
else
{
if(n&)
puts("Brother"); //奇数 win
else
puts("John"); //偶数 win
}
}
return ;
}

HDUOJ----John的更多相关文章

  1. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

  2. John the ripper使用教程

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

  3. HDU 1907 John nim博弈变形

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

  4. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

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

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

  6. John the Ripper

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

  7. 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 ...

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

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

  9. HDU1907 John

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

  10. HDOJ 1907 John

    对于任意一个 Anti-SG 游戏,如果我们规定当局面中所有的单一游戏的 SG 值为 0 时,游戏结束,则先手必胜当且仅当:  (1)游戏的 SG 函数不为 0 且游戏中某个单一游戏的 SG 函数大于 ...

随机推荐

  1. 解决Sqoop报错Could not load db driver class: com.intersys.jdbc.CacheDriver

    报错栈: // :: INFO tool.CodeGenTool: Beginning code generation // :: ERROR sqoop.Sqoop: Got exception r ...

  2. 《CWNA官方学习指南(第3版):认证无线网络管理员PW0-105》

    <CWNA官方学习指南(第3版):认证无线网络管理员PW0-105> 基本信息 原书名:CWNA: Certified Wireless Network Administrator Off ...

  3. 启明星会议室预定系统Outlook版开始支持Exchange2013与Office365版

    版本启明星会议室预定系统支持Exchange2013与微软云服务Office365版.(注意:Exchange2007与Exchange2010也适合此版本) 1.安装 首页,安装类似启明星普通的会议 ...

  4. html 制作复杂table

    数据分析,一般都需要显示数据,就需要使用html做复杂的表格.复杂表格一般是对td的rowspan .colspan属性值. 在html中<td> 标签定义 HTML 表格中的标准单元格. ...

  5. [leetcode]Convert Sorted List to Binary Search Tree @ Python

    原题地址:http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ 题意:将一条排序好的链表转换为二叉查找树 ...

  6. 在web项目启动时执行某个方法

    在web项目中有很多时候需要在项目启动时就执行一些方法,而且只需要执行一次,比如:加载解析自定义的配置文件.初始化数据库信息等等,在项目启动时就直接执行一些方法,可以减少很多繁琐的操作. 在工作中遇到 ...

  7. 宿主机为linux、windows分别实现VMware三种方式上网(转)

    一.VMware三种方式工作原理1 Host-only连接方式  让虚机具有与宿主机不同的各自独立IP地址,但与宿主机位于不同网段,同时为宿主主机新增一个IP地址,且保证该IP地址与各虚机IP地址位于 ...

  8. scala 学习笔记七 基于类型的模式匹配

    1.介绍 Scala 提供了强大的模式匹配机制,应用也非常广泛. 一个模式匹配包含了一系列备选项,每个都开始于关键字 case.每个备选项都包含了一个模式及一到多个表达式.箭头符号 => 隔开了 ...

  9. SecureRandom-随机数的生成

    随机数:算法+种子 随机数据不随机 学习了:https://www.cnblogs.com/deng-cc/p/8064481.html StringBuffer buffer = new Strin ...

  10. iOS-数据库sqlite的使用

    .数据库的增删查改的方法 sqlite3_exec(db, [sql UTF8String], NULL, NULL, &erro); 数据库的使用 步骤:01.导入框架<sqlite3 ...