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. python3.4学习笔记(二十二) python 在字符串里面插入指定分割符,将list中的字符转为数字

    python3.4学习笔记(二十二) python 在字符串里面插入指定分割符,将list中的字符转为数字在字符串里面插入指定分割符的方法,先把字符串变成list然后用join方法变成字符串str=' ...

  2. Javascript 判断对象是否相等

    在Javascript中相等运算包括"==","==="全等,两者不同之处,不必多数,本篇文章我们将来讲述如何判断两个对象是否相等? 你可能会认为,如果两个对象 ...

  3. Postgresql数据库实用命令

    Postgresql 命令 pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 启动数据库 cr ...

  4. 第一个html文件

    1.新建记事本文件,后缀改为.html 2.添加: <html>  <head>  <title>jude`s first web</title>  & ...

  5. Dell Vostro5370安装Win10/Ubuntu18LTS

    如何安装Win10/Ubuntu双系统 测试环境: DELL PRECISION 7510: CPU:Intel Core i5-6300HQ HD:256G NVME SSD 操作步骤: 无损将硬盘 ...

  6. linux交叉编译gcc4.8.3

    1.环境: Ubuntu 16.04 2.获取 wget mirrors.ustc.edu.cn/gnu/gcc/gcc-4.8.3/gcc-4.8.3.tar.bz2 3.解压 tar xvf gc ...

  7. 51nod 1082 与7无关的数

    暴力 打表过的 注意爆int 还有 7的倍数 和 数字中有7的 #include<bits/stdc++.h> using namespace std; typedef long long ...

  8. 51NOD 1432 独木舟(贪心

    1432 独木舟   n个人,已知每个人体重.独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人.显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟? ...

  9. Codeforces 1091 Good Bye 2018

    占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的rating upt:flag竟然没到,开心. A - New Year and the Christmas Ornament 好像没什么可说的. ...

  10. jquery 之 extend的实现

    function getOpt(target, obj1, obj2, obj3){ $.extend(target, obj1, obj2, obj3); return target; } var ...