HDU 1907 (博弈) John
参见上一篇博客,里面有分析和结论。
#include <cstdio> int main()
{
int T; scanf("%d", &T);
while(T--)
{
int n, a, c = , xorsum = ;//c为充裕堆的个数
scanf("%d", &n); while(n--) { scanf("%d", &a); xorsum ^= a; if(a > ) c++; }
if((!xorsum && c >= ) || (xorsum && !c)) puts("Brother");//T2和S0状态必败
else puts("John");//T0和S1和S2状态必胜
} return ;
}
代码君
HDU 1907 (博弈) John的更多相关文章
- HDU 1907:John(尼姆博弈变形)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- HDU 1907 Nim博弈变形
1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...
- S-Nim HDU 1536 博弈 sg函数
S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...
- 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&& hdu 2509 Be the Winner(基础nim博弈)
Problem Description Little John is playing very funny game with his younger brother. There is one bi ...
- HDU - 1907 John 反Nimm博弈
思路: 注意与Nimm博弈的区别,谁拿完谁输! 先手必胜的条件: 1. 每一个小游戏都只剩一个石子了,且SG = 0. 2. 至少有一堆石子数大于1,且SG不等于0 证明:1. 你和对手都只有一种选 ...
- 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 nim博弈变形
John Problem Description Little John is playing very funny game with his younger brother. There is ...
- HDU 1907 John(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
随机推荐
- ASP.NET中数据棒图,饼图,柱状图的实现
Web中绘制图形的方法大致有: 1. VML方式:功能强大,但是非常麻烦. 推荐:http://www.elook.net.cn/vml/ 2.使用控件:Dandus, Aspose.chart,Co ...
- 关于JS中的constructor与prototype
======================================================================== 在学习JS的面向对象过程中,一直对constructo ...
- NET 查找程序集路径(CLR关于Assembly的搜索路径的过程)
最近在回顾.Net应用程序的执行环境,这里做一个很小的总结,方面以后需要的时候进行查找: CLR必须可以找到正确的Assembly,Net提供了Assembly搜索算法,可以根据.config文件(类 ...
- spring事务认识
Spring配置异常回滚采用的是rollback-for=“BusinessException”.来源于java的检查性异常.非检查性异常的区别.使用spring难免要用到spring的事务管理,要用 ...
- Java script 看看黑客怎么写的
在2011年的BlackHat DC 2011大会上Ryan Barnett给出了一段关于XSS的示例java script 代码: ($=[$=[ ] ] [(__=!$+$)[_=-~-~-~$] ...
- 如何在Windows7(IIS7)环境下安装 PHP
一.安装IIS7 打开(1)[程序和功能],然后点击(2)[打开或关闭Windows功能] 勾选(1)[IIS管理控制台]和(2)CGI,然后点击[确定]按钮,等待安装完成.这个过程可能需要系统安装光 ...
- C# WINFORM 捕获全局异常
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Thr ...
- POJ2402/UVA 12050 Palindrome Numbers 数学思维
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- 简单验证码识别 tessnet2
今天突然间对识别验证码感兴趣,于是网上搜了一下 最简单的是引用tessnet2.dll,然后通过它来识别,代码如下 private void button1_Click(object sender, ...
- appserv安装
Appserv 官网: http://www.appservnetwork.com/ 安装好后,输入http://localhost:8082/验证是否装成功,成功后如下图