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. matlab 投影

    function[l]= Gray(I) % I: The name of image A=imread(I);m=0;n=0;[m,n]= size(A);Hproj=zeros(m,1);Vpro ...

  2. 第一个OC的类

    来源:http://www.cnblogs.com/mjios/archive/2013/04/06/3002814.html 本文目录 一.语法简介 二.用Xcode创建第一个OC的类 三.第一个类 ...

  3. Objective-C:随机的读取文件中的内容

    可以通过改变当前文件的偏移量来实现文件的读取 -offsetInFile获取文件当前的位移量 -seekToFileOffset:(NSUInteger)length设置文件当前的位移量 -readD ...

  4. Java 连接MS Access数据库

    java连接MS Access的两种方式: 1.JDBC-ODBC Java连接Access可以使用MS自带的管理工具-->数据源(ODBC)设置建立连接,这样就不需要导入jar.但是,如此一来 ...

  5. 机器学习理论与实战(十一)关联规则分析Apriori

    <机器学习实战>的最后的两个算法对我来说有点陌生,但学过后感觉蛮好玩,了解了一般的商品数据关联分析和搜索引擎智能提示的工作原理.先来看看关联分析(association analysis) ...

  6. HTML标签 闭合还是不闭合?

    你在写 HTML5 代码的时候,是否纠结过应该写 <br /> 还是 <br>,是写 <input /> 还是写 <input>.写 <scrip ...

  7. 转载|23个Python爬虫开源项目代码:爬取微信、淘宝、豆瓣、知乎、微博等

    地址:https://ask.julyedu.com/article/323

  8. vim学习笔记(2)——vim配置

    记录vim的配置,随时更新 MacVim 安装: homebrew,安装位置:/usr/local/Cellar brew linkapps macvim--将macvim.app加入到Applica ...

  9. Linux下面kettle的部署

    一直以来服务器是linux系统,但是感觉linux图形化不强,于是从接触kettle以来都是在windows系统操作ETL的设计和处理.现在需要在linux中查看一下kettle资源库是否连接正常,以 ...

  10. MATLAB数据处理快速学习教程

    转自:http://blog.csdn.net/abcjennifer/article/details/7706581 本篇内容集合了MATLAB中的基本操作.数据存储与计算.数据的直线与曲线拟合与画 ...