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 ...
随机推荐
- 安卓自动化测试工具一:Monkey
一:monkey的用途:主要用于稳定性测试,模拟用户操作 二.monkey的基本使用 monkey文档地址:"<android_sdk>/docs/tools/help/monk ...
- MIT线性代数课程 总结与理解-第一部分
概述 个人认为线性代数从三个角度,或者说三个工具来阐述了线性关系,分别是: 向量 矩阵 空间 这三个工具有各自的一套方法,而彼此之间又存在这密切的联系,通过这些抽象出来的工具可以用来干一些实际的活,最 ...
- C#中的重写和覆盖的区别
#中重写(override)和覆盖(new)的区别 重写用关键字 virtual 修饰的方法,叫虚方法.可以在子类中用override 声明同名的方法,这叫“重写”.相应的没有用virtual修饰的方 ...
- 主成分分析(Principal components analysis)-最大方差解释
原文:http://www.cnblogs.com/jerrylead/archive/2011/04/18/2020209.html 在这一篇之前的内容是<Factor Analysis> ...
- error: a label can only be part of a statement and a declaration is not a statement
GCC: error: a label can only be part of a statement and a declaration is not a statement switch(a){ ...
- Web Scraper使用
{ "selectors": [{ "parentSelectors": ["_root"], "type": &quo ...
- Unity 解决 An asset is marked with HideFlags.DontSave but is included in the build 问题。
问题是:不能使用Unity使用的默认的字体.想要显示中文直接去下载一个字体.没必要使用默认的字体
- nginx 搭建 文件下载服务
location / { root /home/data-nginx/; index index.html index.htm; autoindex on; ##显示索引 autoindex_exac ...
- JQuery 模糊匹配
[属性名称] 匹配包含给定属性的元素 [att=value] 匹配包含给定属性的元素 [att*=value] 模糊匹配 [att!=value ...
- java栈内存堆内存和GC相关
java栈内存堆内存 Java把内存分成两种,一种叫做栈内存,一种叫做堆内存,有着不同的作用.栈内存用来存储局部变量和方法调用.栈内存归属于单个线程,每个线程都会有一个栈内存,其存储的变量只能在其所属 ...