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
|
Sample Output
|
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 ...
随机推荐
- 西邮linux兴趣小组2014纳新免试题(四)
[第四关] 题目 http://findakey.sinaapp.com/ Example: String1:FFFF8 5080D D0807 9CBFC E4A04 24BC6 6C840 49B ...
- 【京东详情页】——原生js爬坑之标签页
一.引言 要做详情页的商品评价等5个li的标签页转换,效果如下: 二.实现原理 有一个特别的地方:上面五个li,但下面只有四个容器(table/div). 设计的目的:无论点哪个li,只有前四个div ...
- 引入Log4j
1. pom文件添加依赖 <!-- log start --> <dependency> <groupId>log4j</groupId> <ar ...
- Spring 学习——基于Spring WebSocket 和STOMP实现简单的聊天功能
本篇主要讲解如何使用Spring websocket 和STOMP搭建一个简单的聊天功能项目,里面使用到的技术,如websocket和STOMP等会简单介绍,不会太深,如果对相关介绍不是很了解的,请自 ...
- Net知识图谱
对于Web系统开发来说,Net其实也是有好多知识点需要学的,虽然目前JAVA是主流,就业市场比较大,但Net也在积极的拥抱开源,大Net Core 2 出来了,这无疑给Net开发者带来更大的希望,好了 ...
- combobox数据获取及使用总结
写在前面 和队友完成工程实践项目过程中遇到combobox数据项加载失败的问题,我将记录下解决该问题中不断填坑的过程. 这是可以确定的填写正确的combobox内容 action也没有错误,Strut ...
- Django 1.10中文文档-执行查询
Django 1.10中文文档: https://github.com/jhao104/django-chinese-doc 只要创建好 数据模型, Django 会自动为生成一套数据库抽象的API, ...
- C# 7.0 新特性:本地方法
C# 7.0:本地方法 VS 2017 的 C# 7.0 中引入了本地方法,本地方法是一种语法糖,允许我们在方法内定义本地方法.更加类似于函数式语言,但是,本质上还是基于面向对象实现的. 1. 本地方 ...
- zoj1002 Fire Net
Fire Net Time Limit: 2 Seconds Memory Limit: 65536 KB Suppose that we have a square city with s ...
- wpf 画刷的分类
System.Windows.Media.Brush最上一层画刷 System.Windows.Media.GradientBrush 线性画刷 ,下层主要有两种画刷 System.Windows. ...