John
John |
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) |
Total Submission(s): 60 Accepted Submission(s): 41 |
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: |
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 |
Sample Output
John |
Source
Southeastern Europe 2007
|
Recommend
lcy
|
/*
题意:有一个盒子,里面装着不同颜色的糖,没人每次只能吃相同颜色的糖。并且最少吃一个,谁吃到最后一个糖就会输
就输。
初步思路:就是裸的尼姆博弈,石头堆换成相同颜色的糖 #错误:少了特判,如果都是1的话,就不需要看异或了。
*/
#include<bits/stdc++.h>
using namespace std;
int t,n,a[];
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
int res=;
while(t--){
scanf("%d",&n);
res=;
int flag=;
for(int i=;i<n;i++){
scanf("%d",&a[i]);
res^=a[i];
if(a[i]>) flag=;
}
if(flag){
printf(res?"John\n":"Brother\n");
}else{
printf(n&?"Brother\n":"John\n");
}
}
return ;
}
John的更多相关文章
- John the ripper使用教程
破解Linux的用户密码:John [跨平台的密码解密工具] root@only:~# unshadow /etc/passwd /etc/shadow > ~/file_to_crack ro ...
- HDU 1907 John nim博弈变形
John Problem Description Little John is playing very funny game with his younger brother. There is ...
- Js-字符串截取substring,分割split,指标indexOf,拼接John
函数:split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组例子: var theString=”jpg|bmp|gif|ico|png”; var arr=theString.spli ...
- John the Ripper
John the RipperJohn the Ripper(简称John)是一款著名的密码破解工具.它主要针对各种Hash加密的密文.它不同于Rainbow Table方式.它采用实时运算的方式和密 ...
- 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 ...
- BZOJ1022 [SHOI2008]小约翰的游戏John
Description 小约翰经常和他的哥哥玩一个非常有趣的游戏:桌子上有n堆石子,小约翰和他的哥哥轮流取石子,每个人取 的时候,可以随意选择一堆石子,在这堆石子中取走任意多的石子,但不能一粒石子也不 ...
- HDU1907 John
Description Little John is playing very funny game with his younger brother. There is one big box fi ...
- HDOJ 1907 John
对于任意一个 Anti-SG 游戏,如果我们规定当局面中所有的单一游戏的 SG 值为 0 时,游戏结束,则先手必胜当且仅当: (1)游戏的 SG 函数不为 0 且游戏中某个单一游戏的 SG 函数大于 ...
- hdu-----2491Priest John's Busiest Day(2008 北京现场赛G)
Priest John's Busiest Day Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- HDU 1907 (博弈) John
参见上一篇博客,里面有分析和结论. #include <cstdio> int main() { int T; scanf("%d", &T); while(T ...
随机推荐
- 翻译:MariaDB wait/nowait
本文为mariadb官方手册:wait/nowait的译文.原文:https://mariadb.com/kb/en/library/wait-and-nowait/ 从MariaDB 10.3.0开 ...
- 翻译:MariaDB字符集和排序规则
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- GitHub使用(一) - 新建个人网站
1.首先进入“仓库Repositories”,点击“新建New”.
- Python实战之列表简单练习
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__ ...
- Java面向对象 Object类 内部类
Java面向对象 Object类 内部类 知识概要: 一:Object类 二:内部类 匿名内部类的写法 1.Object O ...
- 为什么阿里的程序员那么帅?---原来他们都有"编码规约扫描"神器在手
为了迎接十九大的到来,帝都城这几天也是满城风雨,听说早高峰期地铁站的人都排到天桥上了,哎,这就是该死的北漂生活.但是无论怎样,我依然在北京向各位问好! 之前总结过俩篇关于阿里Java开发手册的编程规约 ...
- Appium python自动化测试系列之appium环境搭建(二)
2.1 基础环境搭建 当我们学习新的一项技术开始基本都是从环境搭建开始,本书除了第一章节也是的,如果你连最基础的环境都没有那么我们也没必要去说太多,大概介绍一下: 1.因为appium是支持andr ...
- 深入浅出 Spring
前言:笔记中提供了大量的代码示例,需要说明的是,大部分代码示例都是以图片的形式展示的,所有的图片都是来自本人所敲代码的截图,不足之处,请大家指正~ 第一部分:环境搭建及 IOC 容器 一.Spring ...
- Android Annotations Eclipse 配置 (3)
Android Annotations 本来我想写个 Java 版本的<RESTful客户端库:RestClient>用于 Android 应用开发,结果发现不太好写,虽然用了 Dynam ...
- vue-cli 自定义指令directive 添加验证滑块
vue项目注册登录页面遇到了一个需要滑块的功能,网上看了很多插件发现都不太好用,于是自己写了一个插件供大家参考: 用的是vue的自定义指令direcive,只需要在需要的组件里放入对应的标签嵌套即可: ...