Be the Winner

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

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
题意:同hdu1907  链接
题解:
 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
#define A first
#define B second
const int mod=;
const int MOD1=;
const int MOD2=;
const double EPS=0.00000001;
typedef __int64 ll;
const ll MOD=;
const int INF=;
const ll MAX=1ll<<;
const double eps=1e-;
const double inf=~0u>>;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
int n;
int ans,cou;
int main()
{
while(scanf("%d",&n)!=EOF)
{
ans=cou=;
int exm;
for(int j=; j<=n; j++)
{
scanf("%d",&exm);
ans^=exm;
if(exm>)
cou++;
}
if((ans==&&cou>=)||(cou==&&ans%!=))
printf("No\n");
else
printf("Yes\n");
}
return ;
}

HDU 2509 nim博弈的更多相关文章

  1. HDU 2509 Nim博弈变形

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

  2. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

  3. hdu 1730 Nim博弈

    题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1730 Nim博弈为:n堆石子,每个人可以在任意一堆中取任意数量的石子 n个数异或值为0就后手赢,否则先 ...

  4. HDU - 1850 Nim博弈

    思路:可以对任意一堆牌进行操作,根据Nim博弈定理--所有堆的数量异或值为0就是P态,否则为N态,那么直接对某堆牌操作能让所有牌异或值为0即可,首先求得所有牌堆的异或值,然后枚举每一堆,用已经得到的异 ...

  5. hdu 1907(Nim博弈)

    John Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  6. Hdu 1729 Nim博弈

    点击打开题目链接 之前没做过这题,因为学弟问到我如果来求该题的sg值,才做了这题. 首先, 是多堆Nim博弈毫无疑问,这题是往一个有固定容量的箱子里放石子,和从一堆石子里面拿出石子是一个道理. 和传统 ...

  7. HDU 3032 (Nim博弈变形) Nim or not Nim?

    博弈的题目,打表找规律还是相当有用的一个技巧. 这个游戏在原始的Nim游戏基础上又新加了一个操作,就是游戏者可以将一堆分成两堆. 这个SG函数值是多少并不明显,还是用记忆化搜索的方式打个表,规律就相当 ...

  8. HDU 3389 (Nim博弈变形) Game

    参考了众巨巨的博客,现在重新整理一下自己的思路. 首先在纸上画了一下转移图: 1 3 4号盒子是不能够再转移卡片到其他盒子中去了的,其他盒子中的卡片经过若干步的转移最终也一定会转移到1 3 4号盒子中 ...

  9. HDU 1850 (Nim博弈 取胜方案数) Being a Good Boy in Spring Festival

    考虑到Bouton定理的证明过程,设n个数的Nim和(异或和)为X,其最高位的1在第k位,那么n个数中一定有个y的第k为也是个1. 将y的数量变为X xor y,那么n的数的Nim和为0,便转为先手必 ...

随机推荐

  1. java关于时间

    import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Created b ...

  2. My favorite bit torrent client for Ubuntu

    Deluge Bit Torrent ClientDeluge is among my favorite bit torrent clients for Ubuntu. It is fast, sli ...

  3. AC自动机入门

    Aho-Corasick automaton,该算法在1975年产生于贝尔实验室,是著名的多模式匹配算法之一. KMP算法很好的解决了单模式匹配问题,如果有了字典树的基础,我们可以完美的结合二者解决多 ...

  4. ReentRantLock使用

    synchronized原语和ReentrantLock在一般情况下没有什么区别,但是在非常复杂的同步应用中,请考虑使用ReentrantLock,特别是遇到下面2种需求的时候. 1.某个线程在等待一 ...

  5. Ajax中return false无效 怎么解决?

    var flag=0; $.ajax({ url:"widget?type=member_register&ajax=yes&action=checkname&use ...

  6. IntelliJ IDEA 设置代码提示或自动补全的快捷键

    IntelliJ IDEA 设置代码提示或自动补全的快捷键   点击 文件菜单(File) –> 点击 设置(Settings- Ctrl+Alt+S), –> 打开设置对话框. 在左侧的 ...

  7. putty自动登录

    如果没有公钥/密钥对,就用 PuTTYgen 创建一个,已经有了就可以忽略这一步.一个公钥/密钥对可以用在不同的服务器上,所以也不需要重复创建,关键要有足够强健的密码和安全的存放. 象先前一样输入帐户 ...

  8. 51nod 1134 最长递增子序列

    题目链接:51nod 1134 最长递增子序列 #include<cstdio> #include<cstring> #include<algorithm> usi ...

  9. ArrayList其实就那么一回事儿之源码浅析

    ArrayList 算是常用的集合之一了,不知作为javaner的你有没在百忙之中抽出一点时间看看ArrayList的源码呢. 如果看了,你会觉得其实ArrayList其实就那么一回事儿,对吧,下面就 ...

  10. 编写高质量JavaScript代码的基本要点

    全局变量 javaScript通过函数管理变量作用域.在函数内部声明的变量只在这个函数内部可用,函数外面不可用.另一方面,在任何函数外面声明的或是函数内未声明直接使用的变量叫做全局变量. 每个Java ...