Matches Game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 13264   Accepted: 7712

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

Source

POJ Monthly,readchild
 
AC Code:
#include<cstdio>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n)) {
int ans;
scanf("%d",&ans);
n--;
for(int i=;i<n;i++) {
int x;
scanf("%d",&x);
ans^=x;
}
printf("%s\n",ans?"Yes":"No");
}
}

poj-2234 Matches Game Nim的更多相关文章

  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

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

  3. 题解——POJ 2234 Matches Game

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

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

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

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

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

  6. POJ 2234 Matches Game 尼姆博弈

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

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

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

  8. POJ 2234 Nim博弈

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

  9. POJ 2234

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

随机推荐

  1. go语言中map每次遍历的顺序不同-问题分析

    WHAT? 发现下面这段代码,多次运行出的结果是不一样的 mapper := make(map[int]string) mapper[1] = "1" mapper[2] = &q ...

  2. 解决No 'Access-Control-Allow-Origin' header is present on the requested resource.跨域问题

    跨域错误 错误原因 解决方法在后台写一个过滤器过滤器来改写请求头头 CorsFilter.java public class CorsFilter implements Filter { @Overr ...

  3. 【IDEA】(1)---MAC下常用快捷键

    IDEA常用快捷键 IDEA是一个很好的开发工具,用好它能大大提高我们的开发效率,所以这里学习总结下有关IDEA实用的一些教程,比如常用快捷键,如何自定义代码模版,如何debug异常断点,或者说多线程 ...

  4. 基础查询-SQL和Linq相互化

    目录 SELECT SQL SELECT DISTINCT 语句 WHERE 和 操作符 BETWEEN 和操作符 LIKE 和通配符 ORDER BY 排序 TOP In Alias(as) EXI ...

  5. 无法打开锁文件 /var/lib/dpkg/lock-frontend - open

    转自:https://blog.csdn.net/sinat_29957455/article/details/89036005 在使用apt-get安装程序的时候报: E: 无法打开锁文件 /var ...

  6. 只想听歌曲的高潮部分?让我用python来教你做个音乐高潮提取器!

    有些时候,我们为了设定手机铃声或者发抖音视频时,会耗费大量时间在音乐剪辑上.尤其是想发布大量抖音视频的时候,我们得收集大量的短音乐,这是一个相当耗费时间的工作.那么,这个音乐高潮的提取能不能自动化呢? ...

  7. elasticsearch window下配置安装

    1.首先下载elasticsearch 下载链接:https://www.elastic.co/cn/downloads/elasticsearch 第一张图是下载的,第二章图是下载msi的程序,直接 ...

  8. FCC---Create Visual Direction by Fading an Element from Left to Right---一个带好看背景色的圆形图案,从左到右移动,透明度opacity渐变为0.1,背景色渐渐消失的效果

    For this challenge, you'll change the opacity of an animated element so it gradually fades as it rea ...

  9. Python的4个内置数据结构

    Python提供了4个内置数据结构(内置指可以直接使用,无需先导入),可以保存任何对象集合,分别是列表.元组.字典和集合. 一.列表有序的可变对象集合. 1.列表的创建例子 list1 = []lis ...

  10. Linux 查找目录下大于*M的文件

    1. 查找指定文件夹下等于1M的文件 find ./ -size 1M | wc -l 2. 查找指定文件夹下大于1M的文件 find ./target_path -size +1M | wc -l