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. Visual Studio 发布新版API智能提示

    Visual Studio 新版API智能提示两周前发布.有了它,你可以在调用API的同时,方便了解到API的相关示例代码.这大大地有助于开发人员学习和使用API. 安装方法如下: 1. 打开Visu ...

  2. ComponentOne Xuni助力Xamarin开发者突破百万,快速开发Android、IOS Apps

    在微软Build 2015上,随着VS 2015的预览版发布,Xamrine免费版已经作为VS 2015跨平台移动解决方案的核心.与此同时,Xamarin官方也宣布其用户量达到百万之多.2011年7月 ...

  3. Mac上搭建直播服务器Nginx+rtmp

    简介 nginx是非常优秀的开源服务器,用它来做hls或者rtmp流媒体服务器是非常不错的选择,本人在网上整理了安装流程,分享给大家并且作备忘. 步骤安装 1.安装Homebrow Homebrew简 ...

  4. iOS开发---百度地图配置流程,2.6.0 版本 支持64位

      1.首先需要在百度地图下载最新SDK:地址: http://developer.baidu.com/map/index.php?title=iossdk/sdkiosdev-download 2. ...

  5. 为ubuntu操作系统增加root用户

    1:当安装好虚拟机,安装好Ubuntu操作系统后,登陆的时候发现除了自己的设置的用户就是外来用户,其实Ubuntu中的root帐号默认是被禁用了的,所以登陆的时候没有这个账号,但是如果每次使用root ...

  6. iOS10之后openURL:方法过期之后的替代方法及使用

    目前苹果为iOS10开放了一个key:UIApplicationOpenURLOptionUniversalLinksOnly但亲测无效 目前使用的是这个key:UIApplicationOpenUR ...

  7. Android ImageView的scaleType属性与adjustViewBounds属性(转载)

    ImageView的scaleType的属性有好几种,分别是matrix(默认).center.centerCrop.centerInside.fitCenter.fitEnd.fitStart.fi ...

  8. [原创]推荐一款强大的.NET程序内存分析工具.NET Memory Profiler

    [原创]推荐一款强大的.NET程序内存分析工具.NET Memory Profiler 1 官方网站:http://memprofiler.com/2 下载地址:http://memprofiler. ...

  9. 努力学习 HTML5 (1)—— 初体验

    HTML5 代表未来:W3C ( World Wide Web Consortium, 万维网联盟) 已经放弃 XHTML,从而使 HTML5 成为正式标准并得到认可. 最简单的 HTML5 文档 & ...

  10. JAVA B/S系统实现客户端屏幕截图,Java版的QQ截图

    简介:本方法首先需要抓到屏幕的整个图象,将图象显示在一个JFrame中,再将JFrame全屏显示,这样就模拟出了一个桌面,Java也就可以获得鼠标的作用区域从而实现桌面中的小范围截屏.Java实现QQ ...