http://acm.hdu.edu.cn/showproblem.php?pid=2509

Be the Winner

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

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
 #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,i,a[];
int temp,ans;
while(~scanf("%d",&n))
{
temp=;
ans=-;
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
if(i==)
ans=a[i];
else
ans=ans^a[i];
if(a[i]>)
temp=;
}
if(temp==)
{
if(n%==)
printf("No\n");
else
printf("Yes\n");
}
else
{
if(ans==)
printf("No\n");
else
printf("Yes\n"); }
}
return ;
}

HDU-2509 Be the Winner的更多相关文章

  1. HDU 2509 Be the Winner nim博弈变形

    Be the Winner Problem Description   Let's consider m apples divided into n groups. Each group contai ...

  2. 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 ...

  3. hdu 2509 Be the Winner(anti nim)

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

  4. hdu 2509 Be the Winner 博弈论

    博弈论水题!!! 代码如下: #include<stdio.h> #include<iostream> using namespace std; int main(){ int ...

  5. hdu 2509 Be the Winner 博弈

    题目链接 有n堆苹果, 对于其中的每一堆的x个苹果, 它是放在一条线上的. 你每次可以对一堆苹果进行操作, 可以取y个, 1<=y<=x. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...

  6. (step8.2.2)hdu 2509(Be the Winner——简单博弈)

    题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数....其实理解为什么都没关系, 重要的是,理解就行....).在接下来的一行中,有 ...

  7. HDU 2509 Be the Winner(取火柴博弈2)

    传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...

  8. HDU 2509 Nim博弈变形

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

  9. HDU 2509 基础Anti-SG NIM

    如果我们规定当局面中所有的单一游戏的SG值为0时,游戏结束,则先手必胜当且仅当:(1)游戏的SG!=0 && 存在单一游戏的SG>1:(2)游戏的SG==0  && ...

  10. Be the Winner HDU - 2509(反博弈。。这样叫应该没错吧。。)

    就是   好几堆苹果  每堆苹果排成一条线  可以任意从每堆拿苹果   如果一堆苹果里拿了之后  则有两种情况 1.从不是边缘拿   拿完这一堆变成两堆 2.从边缘拿   拿完还是一堆 题目还要求 谁 ...

随机推荐

  1. (转) Spring读书笔记-----部署我的第一个Spring项目

    一.Spring介绍 Spring是一个轻量级的Java EE容器,它也是一种从实际需求出发,着眼于轻便,灵活,易于开发,易测试和易部署的轻量级开发框架.Spring它完成了大量开发中的通用步骤,留给 ...

  2. Ajax无刷新提交表单和显示

    ajax无刷新表单提交:   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

  3. java: Eclipse jsp tomcat 环境搭建(完整)

    ] 欢迎您! 要学习一门语言,首先要做的就是搭建环境,然后能写一个小的Demo(类似Helloworld),不仅可以建立信心,而且还可以为之后的学习搭建一个验证平台,事半功倍. net领域的vs,号称 ...

  4. 使用Delphi读取网络上的文本文件,html文件

    使用Delphi读取网络上的txt和html文件 可以使用两种方法: 1.下载文件,然后进行读取 下载文件的Delphi代码可以参考: http://www.delphibbs.com/delphib ...

  5. wamp使用方法【总】

    Apache与php配置:我们把php-5.2.9-Win32.zip解压到C盘根目录下,把文件夹名字改成PHP,这样方便一下. 1. 找到PHP目录下的“php.ini-dist”或者“php.in ...

  6. Linq XML

    写得比较啰嗦,自己记载备用   1 public class XmlFunction   2     {   3         private static XDocument _doc = new ...

  7. jQuery easyUI框架中经常出现的问题

    相信开发者对于我们jquery来说都不会陌生吧,jquery为我们的开发提供了很多各式各样的库,满足各种开发的需求,其中我们知道的有轻量级的,但是也有一些基于富客服端的一些重量级库,顾名思义,当我们在 ...

  8. Eclipse反编译工具Jad及插件

    Eclipse反编译工具Jad及插件下载路径 http://download.csdn.net/detail/lijun7788/9689312 http://files.cnblogs.com/fi ...

  9. web版扫雷小游戏(三)

    ~~~接上篇,上篇介绍了游戏实现过程中第一个比较繁琐的地方,现在展现在玩家面前的是一个有血有肉的棋盘,从某种意义上说玩家已经可以开始游戏了,但是不够人性化,玩家只能一个一个节点的点开,然后判断,然后标 ...

  10. LESS快速入门

    Less 简介 简单来说,Less 就是让你在网页设计的时候,可以更方便地写 CSS 的工具. Less官网的说明: LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承,运算,函数. LES ...