hdu 2509 Be the Winner
来源:互联网 发布:吉他软件手机版 编辑:程序博客网 时间:2024/05/07 15:18
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 isthe 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
22 213
Sample Output
NoYes
【题意】
给你很多堆苹果,你有两种选择。
1,选择某一堆,干掉任意数量的。
2,如果某一堆的数量多于两个,你可以选择它,然后分成都不为0的两堆。
【分析】
还是Nim博弈,和hdu1907几乎就是换了个输出方式,不多说。
【代码】
#include <cstdio>#include <cstdlib>#include <cstring>#include <map>#include <list>#include <algorithm>#include <iostream>using namespace std;int len;void ans(void){ int a=0,b=1,c; for(int i=0;i<len;i++) { cin>>c; if(c!=1) b=0; a^=c; } if(b) cout << ((len&1)?"No":"Yes")<<endl; else cout<<(a?"Yes":"No")<<endl;}int main() {// freopen("in.txt","r",stdin); while(scanf("%d",&len)!=EOF) { ans(); } return 0;}
阅读全文
0 0
- hdu 2509 Be the Winner
- HDU 2509 Be The Winner
- hdu-2509 Be the Winner
- hdu 2509 Be the Winner
- HDU 2509 Be the Winner
- HDU 2509 Be the Winner
- HDU 2509 Be the Winner
- HDU 2509 Be the Winner
- hdu 2509 Be the Winner
- hdu 2509 Be the Winner
- HDU 2509 Be The Winner ( Nim 博弈 )
- hdu 2509 Be the Winner 1907 John
- hdu 2509 Be the Winner(博弈)
- hdu 2509 - Be the Winner(简单博弈)
- [博弈]HDU 2509 Be the Winner
- HDU 2509 -Be the Winner/ZOJ3113
- hdu 2509 Be the Winner(博弈)
- hdu 2509 Be the Winner(博弈Nim)
- 232. Implement Queue using Stacks(java)
- Spring框架中的Quartz使用(详解)
- 杭电acm—1306 String Matching
- Redis学习笔记(三)Redis源码解读
- 进程间通信---Messenger
- hdu 2509 Be the Winner
- 多文本显示省略号
- 初学Hibernate学习1 基础知识掌握
- 1002. 写出这个数 (20)
- 【Linux】Netfilter的使用和实现
- Tensorflow学习笔记(1)-Helloworld
- java中堆栈内存分析(String)
- Poj 1383--Labyrinth【树的直径】【bfs】
- global var in head file