题目链接:

https://cn.vjudge.net/problem/POJ-2234

题目描述:

Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of matches, which is taken away, cannot be zero and cannot be larger than the number of matches in the chosen pile). If after a player’s turn, there is no match left, the player is the winner. Suppose that the two players are all very clear. Your job is to tell whether the player who plays first can win the game or not.

Input

The input consists of several lines, and in each line there is a test case. At the beginning of a line, there is an integer M (1 <= M <=20), which is the number of piles. Then comes M positive integers, which are not larger than 10000000. These M integers represent the number of matches in each pile.

Output

For each test case, output "Yes" in a single line, if the player who play first will win, otherwise output "No".

Sample Input

2 45 45
3 3 6 9

Sample Output

No
Yes
 /*
尼姆博弈
异或和等于0,先手必败。
*/
#include<cstdio> int main()
{
int n;
while(scanf("%d",&n) != EOF){
int temp=,x;
for(int i=;i<n;i++){
scanf("%d",&x);
temp ^= x;
} if(temp == )
puts("No");
else
puts("Yes");
}
return ;
}

POJ 2234 Matches Game (尼姆博弈)的更多相关文章

  1. POJ 2234 Matches Game 尼姆博弈

    题目大意:尼姆博弈,判断是否先手必胜. 题目思路: 尼姆博弈:有n堆各a[]个物品,两个人轮流从某一堆取任意多的物品,规定每次至少取一个,多者不限,最后取光者得胜. 获胜规则:ans=(a[1]^a[ ...

  2. POJ2234 Matches Game 尼姆博弈 博弈论

    http://poj.org/problem?id=2234 尼姆博弈(Nimm's Game) 指的是这样一个博弈游戏:有任意堆物品,每堆物品的个数是任意的,双方轮流从中取物品,每一次只能从一堆物品 ...

  3. POJ 2234 Matches Game(Nim博弈裸题)

    Description Here is a simple game. In this game, there are several piles of matches and two players. ...

  4. POJ 3480 &amp; HDU 1907 John(尼姆博弈变形)

    题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Descri ...

  5. POJ 2975 Nim 尼姆博弈

    题目大意:尼姆博弈,求先手必胜的情况数 题目思路:判断 ans=(a[1]^a[2]--^a[n]),求ans^a[i] < a[i]的个数. #include<iostream> ...

  6. hdu 4315 Climbing the Hill && poj 1704 Georgia and Bob阶梯博弈--尼姆博弈

    参考博客 先讲一下Georgia and Bob: 题意: 给你一排球的位置(全部在x轴上操作),你要把他们都移动到0位置,每次至少走一步且不能超过他前面(下标小)的那个球,谁不能操作谁就输了 题解: ...

  7. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

    Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

  8. POJ1704 Georgia and Bob 博弈论 尼姆博弈 阶梯博弈

    http://poj.org/problem?id=1704 我并不知道阶梯博弈是什么玩意儿,但是这道题的所有题解博客都写了这个标签,所以我也写了,百度了一下,大概是一种和这道题类似的能转换为尼姆博弈 ...

  9. POJ2975 Nim 博弈论 尼姆博弈

    http://poj.org/problem?id=2975 题目始终是ac的最大阻碍. 问只取一堆有多少方案可以使当前局面为先手必败. 显然由尼姆博弈的性质可以知道需要取石子使所有堆石子数异或和为0 ...

随机推荐

  1. numpy和pandas和matplotlib用法

    numpy result = [ [0, 10, 20, 30, 40], [10, 23, 33, 43, 53], [20, 83, 23, 55, 33], [30, 93, 44, 22, 5 ...

  2. Python自动化开发 - 函数式编程

    本节内容 一.函数式编程 二.高阶函数 1.变量可以指向函数 2.函数名也是变量 3.传入函数 三.返回函数 1.函数作为返回值 2.闭包特性 一.函数式编程 函数是Python内建支持的一种封装,我 ...

  3. [mysql语句] mysql 语句收集

    // http://stackoverflow.com/questions/6666152/mysql-order-by-where 1. "select * from t_activity ...

  4. WebApi使用JWT认证

    https://www.cnblogs.com/wangyulong/p/8727683.html https://blog.csdn.net/kebi007/article/details/7286 ...

  5. spring mvc请求过程

    spring mvc处理请求过程 1.    首先客户端发送一个HTTP请求,Web服务器接收这个请求,如果匹配DispatcherServlet的请求映射路径,web容器将请求转交给Dispatch ...

  6. 分享自己使用的在线UML画图工具

    刚接触UML时间不长,看了N多教学视频,下载好了几个软件各种不习惯 当我遇见了ProcessOn  从此我彻底“爱上”了它! http://www.processon.com/ UML各类例图它几乎全 ...

  7. SSD 相关基础知识

    SDD 基础知识 SSD(Solid State Drives)是固态硬盘,使用闪存颗粒来存储数据,闪存又可分为NAND Flash和NOR Flash,通常所说的SSD硬盘都使用NAND Flash ...

  8. WinForm中实现Loading加载界面

    1,LoaderForm窗体中添加PictureBox,然后添加Loading图片 2,窗体内属性设置 StartPosition :CenterScreen在屏幕中心显示 TopMost:True置 ...

  9. springBoot2 基础语法

    请求响应 request对象 request 对象其实是HttpServletRequest 类型, 通过它可以获取请求相关的一切信息, 包含请求信息 . 以及请求参数 ,甚至可以当成往里面存储数据[ ...

  10. [LNOI2014]LCA(树剖+线段树)

    \(\%\%\% Fading\) 此题是他第一道黑题(我的第一道黑题是蒲公英) 一直不敢开,后来发现是差分一下,将询问离线,树剖+线段树维护即可 \(Code\ Below:\) #include ...