Be the Winner

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4699    Accepted Submission(s): 2576

Problem Description
Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is 
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
 
Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
 
Output
If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
 
Sample Input
2
2 2
1
3
 
Sample Output
No
Yes
 
Source
 

一开始没注意到0态是胜态这个条件,想成sg来做了,结果WA。

这个题目参考1709的证明过程,不同的地方在于这个可以将一堆取走一部分之后再把剩下的分成两堆,有趣啊,

但是按照上述证明即使有这个条件依然不影响结论的正确性,所以可以直接套用。

  

 #include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,m;
while(cin>>n){
int a,sg=,tot=;
for(int i=;i<=n;++i){
cin>>a;
sg^=a;
if(a==) tot++;
}
if( (tot==n&&sg==) || (tot!=n&&sg!=)) puts("Yes");
else puts("No");
}
return ;
}

hdu-2509-反nim博弈的更多相关文章

  1. hdu2509Be the Winner(反nim博弈)

    Be the Winner Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  2. hdu1907John(反nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  3. LightOJ 1253 Misere NIM(反NIM博弈)

    Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, eac ...

  4. 反Nim博弈

    原文地址:https://blog.csdn.net/xuejye/article/details/78975900 在尼姆博奕中取完最后一颗糖的人为赢家,而取到最后一颗糖为输家的就是反尼姆博奕.这道 ...

  5. HDU 1907 John nim博弈变形

    John Problem Description   Little John is playing very funny game with his younger brother. There is ...

  6. 博弈论中的Nim博弈

    瞎扯 \(orzorz\) \(cdx\) 聚聚给我们讲了博弈论.我要没学上了,祝各位新年快乐.现在让我讲课我都不知道讲什么,我会的东西大家都会,太菜了太菜了. 马上就要回去上文化课了,今明还是收下尾 ...

  7. HDU 2509 Nim博弈变形

    1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

  8. hdu 1907 John&& hdu 2509 Be the Winner(基础nim博弈)

    Problem Description Little John is playing very funny game with his younger brother. There is one bi ...

  9. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

  10. hdu 1730 Nim博弈

    题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1730 Nim博弈为:n堆石子,每个人可以在任意一堆中取任意数量的石子 n个数异或值为0就后手赢,否则先 ...

随机推荐

  1. 微服务:Java EE的拯救者还是掘墓人?

    有人认为,微服务的大行其道是在给Java EE下达死刑判决书.也有人认为,Java EE已死的论调可笑至极.读者朋友,你们怎么看? 引言 有人说,Java确实过于臃肿,经常“小题大做”.但PHP.No ...

  2. 根据wsdl文件,soupUI生成webservice客户端代码

    根据wsdl文件,soupUI生成webservice客户端代码 功能介绍: 对于面向WebServie接口开发时,当我们已经获取到WSDL文件后,可以使用soapUI工具生成对应的客户端和服务端代码 ...

  3. nginx location正则写法

    nginx location正则写法 一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location / { # ...

  4. 01: shell基本使用

    目录: 1.1 编写登录欢迎脚本 1.2 重定向与管道操作 1.3 使用shell变量 1.4 特殊的shell变量 1.5 read与echo使用比较 1.1 编写登录欢迎脚本返回顶部 (1)新建脚 ...

  5. P3938 斐波那契

    思路 脑子还真的是好东西,自己太笨了 容易发现父亲节点和儿子节点的关系 儿子节点大于父亲节点 儿子节点和父亲节点之差为斐波那契数,且斐波那契数为小于儿子节点的最大的一个 1e12中有60左右的斐波那契 ...

  6. require的压缩命令

    注意点 node r.js -o baseUrl=js name=main out=js/build.js paths.jquery=empty: 注:baseUrl是可选的 取决于页面是否有写这个入 ...

  7. C#学习笔记(七):结构体、数组、冒泡排序和调试

    结构体 结构体不能重写默认无参构造函数 一位数组 using System; using System.Collections.Generic; using System.Linq; using Sy ...

  8. Window下Latex加速编译方法以及西农毕设论文模板推荐

    近些日子用Latex写了一遍文章,一共有11页,但是在window下编译需要2分多的时间,使用的是xeletex编译器. 经过查找,得到了以下方法: 如果坚持使用windows下的latex,使用以下 ...

  9. Elasticsearch 原理

    Elasticsearch简介 Elasticsearch是一个基于Apache lucene的实时分布式搜索.具有以下优点: 1.实时处理大规模数据.2.全文检索,能够做到结构化检索和聚合分析.3. ...

  10. Python CSV Reader/Writer 例子--转载

    CSV(comma-separated values) 是跨多种形式导入导出数据的标准格式,比如 MySQL.Excel. 它以纯文本存储数和文本.文件的每一行就代表一条数据,每条记录包含了由逗号分隔 ...