hdu2509Be the Winner (尼姆博弈,注意全为1的情况)
2014-02-25 18:09
337 查看
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
Sample Output
[/code]
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[code]#include<stdio.h> int main() { int n,a,c,t; while(scanf("%d",&n)==1) { c=0;t=0; for(int i=0;i<n;i++) { scanf("%d",&a); c^=a; if(a>1) t=1; } printf("%s\n",(c!=0&&t||c==0&&t==0)?"Yes":"No"); } }
[/code]
相关文章推荐
- 网络IPC:套接字之数据传输
- 基本的SQl语句:update table1 set field1=value1 where 范围
- AutoMapper在MVC中的运用04
- Android中RelativeLayout各个属性的含义
- hbase 数据写入过程习知
- Oracle dblink详解(转)
- 写 mysql配置参数 ing
- Linear or non-linear shadow maps?
- 把数字转换为大写汉字
- JDBC
- JAVA中Swing的应用的实现
- 设计模式
- 使用fragment注意事项
- sizeof()和 strlen()函数
- oracle10查看用户权限
- How to build & install GLFW 3 and use it in a Linux project
- android中的自动补全,autoCompleteTextView 的使用
- 软件工程需求分析
- Java文件写入文本内容方法
- ios socket通讯注意事项