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. [ACM_数学] 大菲波数 (hdu oj 1715 ,java 大数)

    大菲波数 Problem Description Fibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3.计算第n项Fibonacci数值.   ...

  2. Linux:文件类型和权限

    一个目录要同时具有读权限和执行权限才可以打开,而一个目录要有写权限才允许在其中创建其它文件.

  3. paip. 内存占用少的php ide选择评测总结

    paip. 内存占用少的php ide选择评测总结 php ide主要以内存占用为标准进行评测.. 其次以软件体积为标准.. 作者Attilax  艾龙,  EMAIL:1466519819@qq.c ...

  4. 安装Vmware workstation虚拟机(含软件和注册码)

    1:虚拟机的安装步骤,包含软件包和注册码.本博客所使用的虚拟机版本是vmware-workstation_11.1.0版本,注意不是最新版本, 软件包:http://pan.baidu.com/s/1 ...

  5. Android 开发:view的几种布局方式及实践

    View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...

  6. JavaScript 语句 while

    while 语句用法 与for语句的用法之间的关系 for(i==1;i<5;i++) {document.write("12378<br />")  } 若使用 ...

  7. time

    http://blog.csdn.net/JGood/archive/2010/04/07/5457284.aspx    Python提供了多个内置模块用于操作日期时间,像calendar,time ...

  8. Unity3D编程学习分享

    学习地址:http://www.ixueyun.com/lessons/detail-lessonId-692.html 一.课程概述: 以前大部分3D游戏出现在pc和ps.XBox等专业游戏主机上, ...

  9. Disable multi finger touch in my app

    http://stackoverflow.com/questions/12777435/disable-multi-finger-touch-in-my-app android:splitMotion ...

  10. Java 中的instanceof简单讲解

    Java 中的instanceof 运算符是用来在运行时指出对象是否是特定类的一个实例.instanceof通过返回一个布尔值来指出,这个对象是否是这个特定类或者是它的子类的一个实例. 用法:resu ...