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 英文中属性的意思.属性不可以修改,也就是属性不可以由组件进行修改,组件的属性是由父组件传递过来的,相当于组件在出生的时候带的.用法第一种:直接在调用组 ...
随机推荐
- 4、Vim编辑器与正则表达式-面试题
题目 自己写答案
- java多线程与线程并发四:线程范围内的共享数据
当多个线程操作同一个共有数据时,一个线程对共有数据的改变会影响到另一个线程.比如下面这个例子:两个线程调用同一个对象的的方法,一个线程的执行结果会影响另一个线程. package com.sky.th ...
- JavaScript 运行原理
i{margin-right:4px;margin-top:-0.2em}.like_comment_tips .weui-icon-success{background:transparent ur ...
- lufylegend.js教程(1)
1.图片元素如何缩小? 在LSprite类中,有两个属性:{scaleX,scaleY},这两个属性属于按比例缩放精灵对象,可以放大,可以缩小,注意这两个属性是在图片中心点位置开始缩放. 代码: Bo ...
- nyoj 44-子串和(子串和最大问题)
44-子串和 内存限制:64MB 时间限制:5000ms Special Judge: No accepted:12 submit:48 题目描述: 给定一整型数列{a1,a2...,an},找出连续 ...
- 插入订单并且输出订单号的sql存储过程
--插入订单-- create proc InsertOrders ( @OrderNumber varchar(300), @OrderState varchar(30), @OrderType v ...
- 【Mac】【SoupUI】许可证损坏问题
近期参考 https://www.cnblogs.com/shuaijie/articles/5913750.html#top 安装破解SoupUI 破解方法如下: 截至2014-10-9:SoapU ...
- 20191010-9 alpha week 1/2 Scrum立会报告+燃尽图 07
此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/8752 一.小组情况 队名:扛把子 组长:迟俊文 组员:宋晓丽 梁梦瑶 韩昊 ...
- 使用node.js开发一个生成逐帧动画小工具
在实际工作中我们已经下下来不下于一万个npm包了,像我们熟悉的 vue-cli,react-native-cli 等,只需要输入简单的命令 vue init webpack project,即可快速帮 ...
- 数据类型-Java基础一-初学者笔记
初学者笔记 1.Java中的两种类型 在java源代码中,每个变量都必须声明一种类型(type). 有两种类型:primitive type和reference type.引用类型引用对象(ref ...