Be the Winner

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

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

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

刚做完南理工的校外镜像赛,就在HUD上看到这个题,我嘞个坑啊,简直和最强战舰一模一样,除了输入输出(https://icpc.njust.edu.cn/Contest/749/H/),怪不得这么多人过了;

题意应该很好懂吧,n堆苹果,每次从一堆中拿任意个,最后拿的输,问先拿者是否能赢?????

题解请看:http://blog.csdn.net/nyist_tc_lyq/article/details/51180906-我的另一篇博客,题意都是一样的,那有具体的思路题解;

AC代码:

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=100+10;
int a[N];
int main()
{
int n,i,j,x;
while(~scanf("%d",&n))
{
x=j=0;
int f;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
x^=a[i];
if(a[i]>=2)
j++;
}
if(x!=0)
{
if(j==0)
f=1;
else
f=2;
}
else
{
if(j==0)
f=2;
else
f=1;
}
if(f==1)
printf("No\n");
else
printf("Yes\n");
}
return 0;
}

HDU-2509-Be the Winner,博弈题~~水过~~的更多相关文章

  1. hdu 2509 Be the Winner 博弈

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

  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 nim博弈变形

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

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

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

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

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

  6. hdu 2509 Be the Winner 博弈论

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

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

  8. HDU 2509 Nim博弈变形

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

  9. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

随机推荐

  1. [在读]webkit技术内幕

    看了一点点,还不适合目前的我看,搁置.

  2. 搜狐前端css常用命名

  3. 释放资源的一般范式——更锋利的C#代码小记

    public class Photo : IDisposable { //在Finalize函数中调用内部的Dispose方法 ~Photo() { //被自动回收时仅释放托管资源,不释放非托管资源 ...

  4. AJPFX总结方法重载与方法重写的区别

    方法重载在同一个类中,可以出现同名方法,但是这些同名方法的参数列表必须不同,这样定义方法叫做方法重载.方法重载的特点重载的注意事项重载与返回值无关重载与具体的变量标识符无关重载只与方法名与参数相关重载 ...

  5. ios 微信环境 axios请求 status 0

    做了一个支付页面,调用post请求但是请求status 0,出现这个的原因居然是https的网页请求http的数据. 但是这个再ios里面不会报错,安卓正常. 记录一下客户端的这个特征!

  6. IP查询系统的异步回调案例

    package com.lxj.demo; import java.io.BufferedReader; import java.io.IOException; import java.io.Inpu ...

  7. 在2015年 开发一个 Web App 必须了解的那些事

    在过去的一年里,我在从头开始开发我的第一个重要的Web应用.经验教会了很多以前不知道的东西,特别是在安全性和用户体验方面. 值得一提的是,我上一次尝试构建的任何合理复杂性是在2005年.所以,在安全防 ...

  8. System.currentTimeMillis()与日期之间的相互转换

    System.currentTimeMillis()与日期 之间是可以相互转换的,大多数Android开发者都知道 通过 SimpleDateFormat dateformat = new Simpl ...

  9. Android系统固件定制方式

    target_product.mkAndroid系统在构建关于某种产品的固件时,一般会根据特定于该产品的具体target_product.mk来配置生成整个Android系统./target_prod ...

  10. vc枚举本机端口信息API

    常用的获取端口信息的函数: GetTcpTableGetExtendedTcpTableGetUdpTableGetExtendedUdpTable GetTcp6Table function Get ...