Diciption
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 anti_nim游戏。
这种Nim是不能操作者赢。
Sg函数的话还是和普通的Nim一样,初始化是sg[0]=0;
最后游戏的和的话,先手必胜当且仅当:
1.每一堆石子都是1并且Nim和为0.
2.有至少一堆石子>1并且Nim和不为0.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int sg[105],n,m;
int now,v[1005]; inline void init(){
sg[0]=0;
for(int i=1;i<=100;i++){
now=0;
for(int j=0;j<i;j++)
for(int k=j;k+j<i;k++) v[sg[j]^sg[k]]=i;
while(v[now]==i) now++; sg[i]=now;
}
} int main(){
init(); while(scanf("%d",&n)==1){
bool flag=0;
int a,ans=0; while(n--){
scanf("%d",&a);
ans^=sg[a];
if(a>1) flag=1;
} if((!flag&&!ans)||(flag&&ans)) puts("Yes");
else puts("No");
} return 0;
}

  

 

Hdoj 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 Be the Winner

    http://acm.hdu.edu.cn/showproblem.php?pid=2509 Be the Winner Time Limit: 2000/1000 MS (Java/Others)  ...

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

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

随机推荐

  1. oracle 基本函数

    1)字符串函数---length()函数 用于返回字符串长度  select t.name,length(t.name) from tb_person t 2)向左补全字符串---LPAD()函数 L ...

  2. hdu3374 String Problem 最小最大表示法 最小循环节出现次数

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

  3. 1、IOS学习计划

    2015年12月10日 -- 2015年12月27日(一共3个周末,12个个工作日) 1.斯坦福公开课(IOS7应用开发) 一共18节课程,通过视频和demo建立感觉 2.千峰的OC课程 一共25节课 ...

  4. 54、edittext输入类型限制为ip,inputType应该如何设置

    <EditText android:id="@+id/et_setting_printer_edit_info_ip" android:layout_width=" ...

  5. 46、android studio第一次使用时卡在gradle下载怎么解决?

    如果没法FQ或者FQ后网速慢,哥教你一个快速解决方案. 在根目录下的.gradle目录下,找到wrapper/dists目录,如果当前正在下载gradle.x.xx-all.zip,那么会发现grad ...

  6. BugKu-妹子的陌陌

    打开后看这张图片,先放winhex里面,文件头FFD8,是jpg图片.看文件尾并不是FFD9,所以binwalk分析一下. 发现有一个rar文件,然后用foremost分离.发现里面有个加密的rar文 ...

  7. php 判断一个点是否在一个多边形区域内

    <?php class pointMap{ private static $coordArray; private static $vertx = []; private static $ver ...

  8. 01背包 HDU-1203

    这道题在网上找的题解基本都是用min找出概率最小,然后用1减去的答案,我在这采用max来做,虽然只是换了公式,但是其中出现的问题还是想记录下. I NEED A OFFER! Time Limit: ...

  9. Leetcode 623.在二叉树中增加一行

    在二叉树中增加一行 给定一个二叉树,根节点为第1层,深度为 1.在其第 d 层追加一行值为 v 的节点. 添加规则:给定一个深度值 d (正整数),针对深度为 d-1 层的每一非空节点 N,为 N 创 ...

  10. c#每循环100次提交一次数据,最后一次不足100次提交一次

    StringBuilder sb=new StringBuilder(); string strId=dataGridView1.Rows[dataGridView1.CurrentRow.Index ...