Hdoj 2509 Be the Winner
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的更多相关文章
- HDU 2509 Be the Winner nim博弈变形
Be the Winner Problem Description Let's consider m apples divided into n groups. Each group contai ...
- 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 ...
- 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 ...
- hdu 2509 Be the Winner 博弈论
博弈论水题!!! 代码如下: #include<stdio.h> #include<iostream> using namespace std; int main(){ int ...
- hdu 2509 Be the Winner 博弈
题目链接 有n堆苹果, 对于其中的每一堆的x个苹果, 它是放在一条线上的. 你每次可以对一堆苹果进行操作, 可以取y个, 1<=y<=x. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...
- (step8.2.2)hdu 2509(Be the Winner——简单博弈)
题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数....其实理解为什么都没关系, 重要的是,理解就行....).在接下来的一行中,有 ...
- HDU 2509 Be the Winner(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
- HDU-2509 Be the Winner
http://acm.hdu.edu.cn/showproblem.php?pid=2509 Be the Winner Time Limit: 2000/1000 MS (Java/Others) ...
- Be the Winner HDU - 2509(反博弈。。这样叫应该没错吧。。)
就是 好几堆苹果 每堆苹果排成一条线 可以任意从每堆拿苹果 如果一堆苹果里拿了之后 则有两种情况 1.从不是边缘拿 拿完这一堆变成两堆 2.从边缘拿 拿完还是一堆 题目还要求 谁 ...
随机推荐
- BZOJ 4393: [Usaco2015 Dec]Fruit Feast
DP #include<cstdio> using namespace std; int T,A,B,F[5000005],G[5000005]; int main(){ scanf(&q ...
- NOS直传加速服务
本文来自网易云社区 作者:孙建良 最近团队在对存储系统做一些性能测试,期间遇到了不少问题,测试过程中得出的结果也没有很好的数据支撑,所以尝试了非常多的方法来对性能问题进行定位. 小王童鞋是挺厉害的,使 ...
- Marketing learning-2
Part three 1.strategies for leadership 1)operational excellence:operational competence 2)performance ...
- ios开发学习笔记040-autolayout 第三方框架Masonry
不管是是界面创建约束还是代码创建约束,苹果官方提供的方式都比较繁琐.所以出现了第三方框架. Masonry 在github地址如下: https://github.com/SnapKit/Masonr ...
- flask url_for()和redirect的区别
一. 两者用来重定向的时候,被操作的对象不同. redirect直接是url,就是app.route的路径参数. url_for()是对函数进行操作. from flask import Flask, ...
- 使用Fiddler对Android应用进行抓包
1. 打开Fiddler软件,效果图如下: 2. 首先,确保安装 Fiddler 的电脑和你的手机在同一局域网内,因为Fiddler只是一个代理,需要将手机的代理指向 PC 机,不能互相访问是不行的 ...
- Jmeter随笔一
资料分享:http://www.cnblogs.com/yangxia-test/p/3964881.html
- python学习-- django 2.1.7 ajax 请求 进阶版
#原来版本 $.get("/add/",{'a':a,'b':b}, function(ret){ $('#result').html(ret)}) #进阶版 $.get(&qu ...
- 数据结构设计 Stack Queue
之前在简书上初步总结过几个有关栈和队列的数据结构设计的题目.http://www.jianshu.com/p/d43f93661631 1.线性数据结构 Array Stack Queue Hash ...
- pdo防sql注入
http://blog.csdn.net/qq635785620/article/details/11284591