HDU 1907 John(取火柴博弈2)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,a,res=0;
int c=0,g=0;//¹Âµ¥¶Ñ¡¢³äÔ£¶Ñ
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a);
if(a>=2) c++;
else if(a==1) g++;
res^=a;
}
if(!res)//Òì»òΪ0£¬ÎªT̬
{
if(c>=2)//T2
printf("Brother\n");
else if(c==0)
printf("John\n");
}
else//S
{
if(g&1&&c==0)//S0
printf("Brother\n");
else if(c==1||c>=2)//S1,S2
printf("John\n");
}
}
return 0;
}
HDU 1907 John(取火柴博弈2)的更多相关文章
- HDU - 1907 John 反Nimm博弈
思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1. 每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选 ...
- HDU 1907 John (Nim博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- hdu 1907 John (尼姆博弈)
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 nim博弈变形
John Problem Description Little John is playing very funny game with his younger brother. There is ...
- 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&& hdu 2509 Be the Winner(基础nim博弈)
Problem Description Little John is playing very funny game with his younger brother. There is one bi ...
- HDU 2509 Be the Winner(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
- hdu 1907 (尼姆博弈)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907 Problem Description Little John is playing very ...
随机推荐
- codevs1069关押罪犯(并查集)
题目描述 Description S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极 不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用“怨 ...
- redis服务器安装-SuSE Linux Enterprise Server 11 SP3
一.下载 官网下载,可自选版本,点击进入下载,这里下载了redis-3.2.4 放到 /root/usr/local/redis/ 目录下 二.编译 1. 执行make编译redis tar -zxz ...
- CoreJavaE10V1P3.6 第3章 Java的基本编程结构-3.6 字符串 String
String类(java.lang.String)就是Unicode字符序列,例如:"Java\u2122" 3.6.1 Substring 提取子串 String greetin ...
- android 沉浸式状态栏的实现
本文介绍一种简单的实现沉浸式状态栏的方法,要高于或等于api19才可以. 实现android沉浸式状态栏很简单,添加代码两步就可以搞定. 一.在activity中添加 getWindow().addF ...
- Webupload + MVC 之上传下载
最近工作中用到了 MVC 的上传及下载 , 写下感受 本项目中用到的是百度的webuploader <!--引入Jquery--> <script src="~/Conte ...
- aforge通过角点匹配图片相似度
我不知道什么原因,人品不好还是啥的 ExhaustiveTemplateMatching这个类无法高精确度的匹配图片 ........... 换一种方式,就好得多 /// <summary> ...
- python3 流程控制
表达式if ... else >>> if 3 > 4: ... print('False') ... else: ... print('True') ... True 表达式 ...
- Beego学习笔记——Config
配置文件解析 这是一个用来解析文件的库,它的设计思路来自于database/sql,目前支持解析的文件格式有ini.json.xml.yaml,可以通过如下方式进行安装: go get github. ...
- 转:【iOS开发每日小笔记(十一)】iOS8更新留下的“坑” NSAttributedString设置下划线 NSUnderlineStyleAttributeName 属性必须为NSNumber
http://www.bubuko.com/infodetail-382485.html 标签:des class style 代码 html 使用 问题 文件 数据 ...
- putty 使用 注意事项
putty命令行模式,修改文本 小心数字小键盘 变命令!! 务必在putty--选项 Terminal->Features 里,找到 Disable application keypad mod ...