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. php-laravel框架用户验证(Auth)模块解析(一)

    一.初始化 使用php artisan命令进行初始化:php artisan make:auth 和 php artisan migrate(该命令会生成users表.password_resets表 ...

  2. Spring Boot2 系列教程(二十二)整合 MyBatis 多数据源

    关于多数据源的配置,前面和大伙介绍过 JdbcTemplate 多数据源配置,那个比较简单,本文来和大伙说说 MyBatis 多数据源的配置. 其实关于多数据源,我的态度还是和之前一样,复杂的就直接上 ...

  3. WPF属性绑定实现双向变化

    WPF依赖项属性可以实现属性的绑定,成功绑定之后只要修改后台绑定的属性,即可UI同步自动更新绑定的值,无需手动刷新界面:同样,前台的值变化后,通过获取绑定的属性值也可获取UI变化后的值,实现双向变化的 ...

  4. 禁止页面被复制和禁止右键,一段样式一段JS就行了,无需复杂设定!

    群里小伙伴经常问怎么禁止页面复制和右键,其实这个问题百度一下是很多资料的,我估计小伙伴都懒,所以这里统一回复下: 找到模板里面的</head>,在上面加如下代码就行了 <style ...

  5. Tasteless challenges hard WP

    hard Level 5- Fred CMS 十有八九是注入,不过测试引号和转义符并没发现什么,于是跑了下密码字典,竟然发现网页提示 sql injection detected! ,然后发现原来是密 ...

  6. requests---参数关联

    在做接口测试的过程中,我们经常会遇到参数关联,也就是我们经常所说的上一个接口返回是下一个接口的请求 参数关联 在应用业务接口中,完成一个业务功能时,有时候一个接口可能不满足业务的整个流程逻辑,需要多个 ...

  7. JSP知识总结

    day11 JSP入门 1 JSP概述 1.1 什么是JSP JSP(Java Server Pages)是JavaWeb服务器端的动态资源.它与html页面的作用是相同的,显示数据和获取数据. 1. ...

  8. centos7.6离线安装mysql5.7(附下载链接)

    本来打算直接用原生yum源安装,但是跨国访问网络太慢,只好采用离线安装的方式,原理就是把所需的rpm下载下来再上传服务器安装. 1.rpm文件下载地址: 目录: http://repo.mysql.c ...

  9. SpringMVC常用注解(三)

    一.@Controller .@RestController 和 @ControllerAdvice 1. @Controller @Controller 用于标记在一个类上,使用它标记的类就是一个S ...

  10. shellnet运行train_val_seg.py

    1.semantic3d数据集准备:prepare_semantic3d_data.py 11个测试数据集(.txt文件): 假如运行的是室外点云数据集“seg_semantic3d”,可能需要做以下 ...