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 ...
随机推荐
- angular中的cookie读写
AngularJS中对cookie的操作封装了一个单独的模块,模块名为ngCookies,若想使用需在页面中先引入angular-cookies.js: <script src="js ...
- C语言指针、地址、赋值三者含义
先来一个观点.大家先看看对不对 按:在CSDN论坛上,有位坛友提到这个问题: ==================================== 先看一段代码: #include<stdi ...
- hdu 1564 Play a game(博弈找规律)
题目:一个n*n的棋盘,每一次从角落出发,每次移动到相邻的,而且没有经过的格子上. 谁不能操作了谁输. 思路:看起来就跟奇偶性有关 走两步就知道了 #include <iostream> ...
- Java: MissingResourceException, "Can't find bundle for base name myMessage, locale zh_CN"
在java中,在多语言国际化时可以用 *.java 类来作为资源文件使用. 1. 首先定义类, 类必须继承ListResourceBundle 类所在路径为: src/I18N public clas ...
- SAP HANA中创建分析权限(Analytic Privilege)
Demo Instruction: 假定CustomerID > 100的为VIP客户,我们的权限设置为只显示VIP客户 所使用的Attribute View: ATTR_CUSTOMER_FU ...
- 【转】SQL Server 2008 事件探查器(SQL SERVER Profiler)
跟踪数据库sql语句的执行情况.例:一个系统,用到了sql server 数据库,这个系统共有500张表,当用户在前台页面做某一个操作时,比如插入,登录等等,我们想知道此刻是在对哪一张表操作,打开事件 ...
- 简单入门使用GitHub总结
简单入门使用GitHub总结 ps: 试着自己弄一下GitHub,发现问题多多,中间还差点把自己的资料给全部弄没了(直接摔啦~). 然后网上查找各种资料进行设置终于成功了. 以下是参考的资料链接: G ...
- CodeForces 710A King Moves
简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...
- ajax使用json
json是什么什么的废话不说了,去百度吧.我这里介绍一下我为何要使用json.我使用ajax响应返回值时,项目中需求要返回多个值,不能只返回一个值.这时候就想起来用到json了.这可能只是json的一 ...
- C# 语言规范_版本5.0 (第13章 接口)
1. 接口 一个接口定义一个协定.实现某接口的类或结构必须遵守该接口定义的协定.一个接口可以从多个基接口继承,而一个类或结构可以实现多个接口. 接口可以包含方法.属性.事件和索引器.接口本身不提供它所 ...