Matches Game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7567   Accepted: 4327

Description

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
题目大意:有N堆石子,每堆M个,每次可以从任意一堆中取走任意个石子,问先手能否获胜。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std; int main()
{
int ans, n, pile[];
while(scanf("%d", &n) != EOF)
{
ans = ;
memset(pile, , sizeof(pile));
for (int i = ; i < n; i++)
{
scanf("%d", &pile[i]);
ans ^= pile[i];
}
if (ans == )
{
printf("No\n");
}
else
{
printf("Yes\n");
}
}
return ;
}

POJ 2234 Matches Game的更多相关文章

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

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

  2. POJ 2234 Matches Game (尼姆博弈)

    题目链接: https://cn.vjudge.net/problem/POJ-2234 题目描述: Here is a simple game. In this game, there are se ...

  3. POJ 2234 Matches Game(取火柴博弈1)

    传送门 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> ...

  4. POJ 2234 Matches Game 尼姆博弈

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

  5. 题解——POJ 2234 Matches Game

    这道题也是一个博弈论 根据一个性质 对于\( Nim \)游戏,即双方可以任取石子的游戏,\( SG(x) = x \) 所以直接读入后异或起来输出就好了 代码 #include <cstdio ...

  6. 【POJ】2234 Matches Game(博弈论)

    http://poj.org/problem?id=2234 博弈论真是博大精深orz 首先我们仔细分析很容易分析出来,当只有一堆的时候,先手必胜:两堆并且相同的时候,先手必败,反之必胜. 根据博弈论 ...

  7. POJ 2234

    #include<iostream> #include<stdio.h> #include<algorithm> #define MAXN 100 using na ...

  8. POJ 2234 Nim博弈

    思路: nim博弈裸题 xor一下 //By SiriusRen #include <cstdio> using namespace std; int n,tmp,xx; int main ...

  9. SG函数和SG定理【详解】

    在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜点和必败点的概念:        P点:必败点,换而言之,就是谁处于此位置,则在双方操作正确的情况下必败.        N点:必胜点 ...

随机推荐

  1. 如何真正重写window对象的方法

    重写window对象的方法不是一件新奇的事,比如我们可能需要改变默认alert的行为,如何安全的重写呢? 小菜看到某知名IT网站是这样的写法: window.alert = function(){}; ...

  2. 深究JS异步编程模型

    前言  上周5在公司作了关于JS异步编程模型的技术分享,可能是内容太干的缘故吧,最后从大家的表情看出"这条粉肠到底在说啥?"的结果:(下面是PPT的讲义,具体的PPT和示例代码在h ...

  3. 文件系统:Ext3和Ext4

    一.ext3和ext4的区别: 1.与Ext3兼容:执行若干条命令,就能将Ext3在线迁移到Ext4,而无须重新格式化磁盘或者重新安装系统.原有Ext3数据结构照样保留, Ext4作用于新数据,当然, ...

  4. jQuery/javascript实现网页注册的表单验证

    <html> <head> <meta charset="utf-8"> <title>注册表单验证</title> & ...

  5. unsigned long类型转换为CString出现的问题

    开发工具:VC2010 财务程序读卡时发现有的卡片读出的卡号异常,代码如下: // 读卡序列号 unsigned long cardNo; CICReader reader(ICREADER_TYPE ...

  6. VS2015 ASP.NET5 Web项目结构浅析

    前言 本文个人同步博客地址http://aehyok.com/Blog/Detail/76.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本 ...

  7. LPC43xx Dual-core or Multi-core configuration and JLink Debug

    Test access port (TAP) JTAG defines a TAP (Test access port). The TAP is a general-purpose port that ...

  8. 【VerySky原创】 ME9F

    [VerySky原创] V_EKKONA - Generierte Tabelle zu einem View V_EKKONA-PFLD4 字段 SE71查看 至于图片:在表STXBITMAPS中 ...

  9. ASP.NET Web API中的参数绑定总结

    ASP.NET Web API中的action参数类型可以分为简单类型和复杂类型. HttpResponseMessage Put(int id, Product item) id是int类型,是简单 ...

  10. C#之读取web上的xml

    一.使用LINQ读取使用Xdocument上的Load方法,可以快速的加载一个XML文档,然后使用LINQ对 加载XML文档进行查询或其他操作,这里仅简单偏历.所以,一旦查询一组元素有返回元素集,就可 ...