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 ...
随机推荐
- 模仿jQuery的filter方法
对这类方法挺感兴趣的,因为方法的回调函数的返回值和jQuery变量好像没有什么关系.看了filter方法的源代码后,我就模仿了这个方法,自定义两个jQuery方法:some和every,类似于ES5新 ...
- [一波低姿势的usaco除草记]
总共花了一个月左右 把一份usaco的总结刷了一遍 应该有一百四十多道题 在此纪念一下 总体来说 发现自己基础不是很稳 基本贪心和一些堆的做法还是有点弱鸡 一些dp还是有点弱 但是数据结构题几乎都可以 ...
- 关于jquery 1.9以上多次点击checkbox无法选择的
在jquery1.9之前,我们对于一个checkbox对象来进行重复选择或者取消, 我们可以使用这个方法$().attr('checked',checked);//选中 $().removeAttr( ...
- MAC OS 常用软件及开发工具
1.各个版本的 Mac OS 链接: http://pan.baidu.com/s/1mgDtCi0 密码: 4y3u 2.Xcode xcode_4.6.3 链接: http://pan.baidu ...
- 修改release management client对应的服务器的地址
参考资料:http://stackoverflow.com/questions/25313053/how-to-change-a-release-management-server-name-in-r ...
- [转]Numpy使用MKL库提升计算性能
from:http://unifius.wordpress.com.cn/archives/5 系统:Gentoo Linux (64bit, Kernel 3.7.1)配置:Intel(R) Cor ...
- Chapter 21_3 模式
很多地方都会看到各种匹配模式,每次接触这些函数,颇使人望文生畏. 今天就来好好面对它.认识它.了解它.最后战胜它. 匹配模式都是用一串常规的字符串来描述,最主要的是理解这些字符串的语法及含义(即它能匹 ...
- Java中的native关键字与JNI
一.先说一下大致的意思: jdk提供的类库源代码中有一些方法没有实现,这些方法前有native关键字,如object类中的 : native Object clone() throws CloneNo ...
- iOS开发系列-UI基础-KVC
这些知识是UI初级学习的,目前我还在学习中,适合初学者看 KVC—Key Value Coding 也就是键值编码 是一种获取值和设置值的方式 当我们创建一个类文件,为这个类设置成员属性的时候: 创建 ...
- C语言之字符串典型例题解析
今天又遇见几个好题,和以前的一些凑一块写一篇文章,作为我延迟去自习室的一个借口吧. 首先是第一题 int fun(char* s){ char* t = s; while(*t++); return ...