HDU1907 Jhon
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.
InputThe 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
OutputOutput 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
题解:考虑多个1的情况
参考代码:
#include<bits/stdc++.h>
using namespace std;
int T,n,ans,x,num; int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);ans=num=;
for(int i=;i<=n;++i) {scanf("%d",&x);ans^=x;if(x>) num++;}
if((!ans&&num>) || (ans&&!num)) puts("Brother");
else puts("John");
} return ;
}
HDU1907 Jhon的更多相关文章
- 尼姆博弈HDU1907
HDU1907 http://acm.hdu.edu.cn/showproblem.php?pid=1907 两种情况1.当全是1时,要看堆数的奇偶性 2.判断是奇异局势还是非奇异局势 代码: #in ...
- *HDU1907 博弈
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- HDU1907 John
Description Little John is playing very funny game with his younger brother. There is one big box fi ...
- hdu1907(anti-sg入门)
改变了下规则,现在变成了最后拿的人输. 如果对于单纯的nim的话,只需要判断每堆都是1个石子的特殊情况. 因为如果存在有大于1个石子的堆话,类似于nim的取法,处于必胜状态的一方只需要在 对方取完后只 ...
- hdu1907 John 博弈
Little John is playing very funny game with his younger brother. There is one big box filled with M& ...
- HDU1907(尼姆博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- hdu1907 尼姆博弈
尼姆博弈的性质. 最后一个取输.若a1^a2^a3...^a4=0表示利他态T,不然为利己态S.充裕堆:1个堆里的个数大于2.T2表示充裕堆大于等于2,T1表示充裕堆大于等于1,T0表示无充裕堆.S2 ...
- sort()基础知识总结+超简短的英文名排序写法
结合前些天学的箭头函数我想到一种非常简短的sort排序写法:(这可能是最短的英文名排序方法了) 贴出来大家一起探讨一下: [4,1,2,32].sort((x,y)=>x>y); //[1 ...
- React学习笔记-8-属性和状态详解
属性的含义和用法props=properties 英文中属性的意思.属性不可以修改,也就是属性不可以由组件进行修改,组件的属性是由父组件传递过来的,相当于组件在出生的时候带的.用法第一种:直接在调用组 ...
随机推荐
- fcgi-2.4.1.tar.gz 和 spawn-fcgi-1.6.4.tar.gz 百度云
链接:https://pan.baidu.com/s/1nEzOkFC0-rfVMDy_BygLWg 提取码:ty0e 美好的东西都是免费滴
- 网站搭建 - IIS 填坑 - 终于建好站了 linux + Windows
之前的IIS可以运行Windows的网页,但是对于php的网页,还是不能够支持,于是决定重新来一遍. (把踩的坑重新描述一下,在下载完php之后,解压后不要急着改文件,跳到最后的页面去改.) 以便能够 ...
- 前端与算法 leetcode 7. 整数反转
目录 # 前端与算法 leetcode 7. 整数反转 题目描述 概要 提示 解析 解法 算法 传入测试用例的运行结果 执行结果 GitHub仓库 # 前端与算法 leetcode 7. 整数反转 题 ...
- Java编程思想——第14章 类型信息(二)反射
六.反射:运行时的类信息 我们已经知道了,在编译时,编译器必须知道所有要通过RTTI来处理的类.而反射提供了一种机制——用来检查可用的方法,并返回方法名.区别就在于RTTI是处理已知类的,而反射用于处 ...
- Netty创建服务器与客户端
Netty 创建Server服务端 Netty创建全部都是实现自AbstractBootstrap.客户端的是Bootstrap,服务端的则是ServerBootstrap. 创建一个 HelloSe ...
- linux命令--文件目录操作命令
一.命令的基本格式 1.命令提示符 [root@love2 ~]# []:这是提示符的分隔符号,没有特殊含义. root:显示的是当前的登录用户. @:分隔符号,没有特殊含义.love2:当前系统的主 ...
- Openlayers Overlay使用心得
Overlay在Openlayers里是浮动层的概念,区别于vector这样的图层,通常用于弹窗.撒点.以及解决加载icon样式不支持的gif等格式图片. 此次用overlay的过程中遇到很多问题,在 ...
- 20191017-7 alpha week 2/2 Scrum立会报告+燃尽图 06
此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9803 一.小组情况 队名:扛把子 组长:迟俊文 组员:宋晓丽 梁梦瑶 韩昊 ...
- Vmware EXSI服务迁移无法访问故障处理
Vmware EXSI服务迁移无法访问故障处理 我们在做微服务平台服务时经常在构建IAAS时,因为硬件资源的扩容.缩减等可维护性问题需要迁移或者复制方式扩容方式来快速扩建集群节点,提高微服务运营的可靠 ...
- Ubuntu--pip3 -V 问题
问题原因:可能是因为重新下载或更新python版本的时候,将系统的‘软连接’破坏掉了 解决办法: 1.重新创建--软连接: 进入bin目录:cd /usr/bin 删除pip3连接:rm pip3 重 ...