HDU-2509-Be the Winner,博弈题~~水过~~
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
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).
2
2 2
1
3
No
Yes
刚做完南理工的校外镜像赛,就在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,博弈题~~水过~~的更多相关文章
- hdu 2509 Be the Winner 博弈
题目链接 有n堆苹果, 对于其中的每一堆的x个苹果, 它是放在一条线上的. 你每次可以对一堆苹果进行操作, 可以取y个, 1<=y<=x. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...
- 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 nim博弈变形
Be the Winner Problem Description Let's consider m apples divided into n groups. Each group contai ...
- (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 博弈论
博弈论水题!!! 代码如下: #include<stdio.h> #include<iostream> using namespace std; int main(){ int ...
- 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 Nim博弈变形
1.HDU 2509 2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- Django framework
1. Django 的内置web server是如何实现的 2. Django 的WSGI是如何实现的 3. Django middle ware是如何实现的 4. Django framework的 ...
- vue_resource 使用说明
前几天用vue-resource调用接口,用post方式给后端,发现后端php接受不到数据,这好奇怪,最后发现提交给后端的时候 需要加一个参数 就是:emulateJSON : true 这句话的意思 ...
- hihocoder1067 最近公共祖先·二
思路: 使用tarjan算法,这是一种离线算法. 实现: #include <bits/stdc++.h> using namespace std; typedef pair<int ...
- const和volatile
const是只读变量 const修饰的变量是只读的,其本质还是变量 const修饰的局部变量在栈上分配空间 const修饰的全局变量在全局数据区分配空间 const只在编译期有用,在运行期无用 con ...
- SQL Server中的事务日志管理的阶梯,级别1:事务日志概述
SQL Server中的事务日志管理的阶梯,级别1:事务日志概述 翻译:刘琼滨 谢雪妮 许雅莉 赖慧芳 级别1:事务日志概述 事务日志是一个文件,其中SQL服务器存储了所有与日志文件关联的数据库执行的 ...
- Spotlight安装
刚才技术群的一个朋友在安装Spotligh出现了一些问题,所以本人临时写个简单的教程 1.下载安装包(安装包地址:https://pan.baidu.com/s/1c2tmqyc),解压,然后傻瓜式安 ...
- ElasticSearch使用spring-data-elasticSearch的用法
spring-data-Elasticsearch 使用之前,必须先确定版本,elasticsearch 对版本的要求比较高. spring和elasticsearch有两种链接方式,一种是用TCP协 ...
- cmd命令002
cd..--> 返回上一级目录 cd\ --> 返回根目录"cd /d e:"--> 将当前盘符切换到e盘,"cd users/admin"- ...
- uva1660 Cable TV Network
点连通度:最少删除几个点使图不连通 拆点就变成了最小割 注意编号.画图就知道u’连v,v’连u. 技巧:不需要枚举S,T.固定S,枚举T即可 这种输入很烦, scanf(" (%d,%d)& ...
- treeTable的使用(ajax异步获取数据,动态渲染treeTable)
一.展示效果(treetable基本样式https://www.cnblogs.com/shuihanxiao/p/10413454.html) 二.html文件(若一个页面又多个treetable, ...