hdu 1907 John (anti—Nim)
John
Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
http://acm.hdu.edu.cn/showproblem.php?pid=1907
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.
– 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
about game winner. Print “John” if John will win the game or “Brother” in other
case.
3
3 5 1
1
1
#include<cstdio>
using namespace std;
int main()
{
int T,n,x,sum,yh;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
sum=yh=;
for(int i=;i<=n;i++)
{
scanf("%d",&x);
yh^=x;
if(x>) sum++;
}
if(yh&&!sum) printf("Brother\n");
else if(!yh&&sum>=) printf("Brother\n");
else printf("John\n");
}
}
hdu 1907 John (anti—Nim)的更多相关文章
- hdu 1907 John(anti nim)
		
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
 - HDU  1907  John (Nim博弈)
		
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
 - POJ 3480 & HDU 1907 John(尼姆博弈变形)
		
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...
 - HDU 1907 John(博弈)
		
题目 参考了博客:http://blog.csdn.net/akof1314/article/details/4447709 //0 1 -2 //1 1 -1 //0 2 -1 //1 2 -1 / ...
 - HDU 1907 John(取火柴博弈2)
		
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
 - hdu 2509 Be the Winner(anti nim)
		
Be the Winner Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
 - HDU 5795 A Simple Nim(简单Nim)
		
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
 - HDU 3533 Escape(大逃亡)
		
HDU 3533 Escape(大逃亡) /K (Java/Others) Problem Description - 题目描述 The students of the HEU are maneu ...
 - HDU 1043 Eight(八数码)
		
HDU 1043 Eight(八数码) 00 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descr ...
 
随机推荐
- 20172332『Java程序设计』课程结对编程练习_四则运算第二周阶段总结
			
20172313『Java程序设计』课程结对编程练习_四则运算第二周阶段总结 小组成员 20172326康皓越 20172313余坤澎 20172332于欣月 小组编程照片 设计思路 设计一个生成符号 ...
 - 解决:Invalid character found in the request target.The valid characters are defined in RFC 7230 and RFC3986
			
目录 背景 原因分析 处理方法 参考 背景 在将tomcat升级到7.0.81版后,发现系统的有些功能不能使用了,查询日志发现是有些地址直接被tomcat认为存在不合法字符,返回HTTP 400错误响 ...
 - CentOS7安装Consul集群
			
1.准备4台服务器 linux1 192.168.56.101 linux2 192.168.56.102 linux3 192.168.56.103 linux4 192.168.56.104 2. ...
 - 自己编写 Oracle 分页函数
			
CREATE OR REPLACE PACKAGE PACK_PAGINATION AS PAGESIZE CONSTANT ; TYPE TYRECORD_EMP IS RECORD( EMPNO ...
 - phpcms 发布时间 更新 时间
 - ConcurrentHashMap原理分析(1.7与1.8)-put和 get 需要执行两次Hash
			
ConcurrentHashMap 与HashMap和Hashtable 最大的不同在于:put和 get 两次Hash到达指定的HashEntry,第一次hash到达Segment,第二次到达Seg ...
 - Java容器深入浅出之List、ListIterator和ArrayList
			
List是Collection接口的子接口,表示的是一种有序的.可重复元素的集合. List接口的主要实现类ArrayList和Vector,底层都是维护了一套动态的,可扩展长度的Object[]数组 ...
 - Graph-Based image segmentation method
			
1.Graph-Based 方法简介 基于图的图像分割方法将图像伪造成带权值无向图的形式 : G = (V, E) 其中,V是顶点集合,把图像中的每个像素或者每个区域看成图的一个顶点:E是边的集合,连 ...
 - python的N个小功能(更新文件)
			
########################################################################## #对于第二份文件:第一份与第二份不相同,以第二份为 ...
 - 中小型园区网络的基本部署之动手划分vlan
			
在计算机网络中,一个二层网络可以被划分为多个不同的广播域,一个广播域对应了一个特定的用户组,默认情况下这些不同的广播域是相互隔离的.不同的广播域之间想要通信,需要通过一个或多个路由器.这样的一个广播域 ...