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 ...
随机推荐
- 前端打印console
很多时候,我们都想知道,是否已经选中或得到数据时,我们可以利用console 打印出来.console有几种方式使用.具体有: console.log($scope.getParkId); conso ...
- AJPFX总结private关键字
private关键字 什么是private关键字? 它是一个修饰符,代表私有的意思,它可以修饰成员变量和成员方法 private关键字的特点? ...
- 获取第三方软件的包名、入口Activity的类名
要启动指定的第三方软件,需要知道第三方软件的包名.类名. 获取第三方软件包名.类名的两种方法: 1.使用aapt aapt是sdk自带一个工具,在 Sdk\builds-tools 目录下 .如果没有 ...
- canvas画笑脸
<style> body { background: black; text-align: center; } #cans { background: white; } < ...
- asp.net 中文部分显示问号
很神奇的事情,今天部署了一个网站,页面从数据读取新闻后,有些新闻标题全部显示问题号,有几个新闻能正确显示汉字,然后查看新闻页面又能正常显示汉字. 解决办法: 在异常的页面上加上 < %@ COD ...
- Handler引起的内存泄露
一般我都写handler的时候是这样的: public class MyActivity extends Activity{ private final Handler myHandler = n ...
- jmeter+ant+jenkins
前提:需要先配置下面两个环境,严格按照本人的配置去配,要不然后面你会看不懂 (1)ant+jmeter集成:http://blog.csdn.net/qq_23101033/article/detai ...
- H3C S5024P交换机 vlan实验
H3C S5024P交换机第二次vlan实验 实验1 与交换机端口G0/1和G0/2相连的PC1与PC2属于VLAN 1,与G0/3和G0/4相连的PC3和PC4属于VLAN 2,PC1.PC2.PC ...
- python基础一 day2
内容: 3%%s 输出:3%s 后面的全部转义 结果: 如果是因为执行break语句导致循环提前结束,就不会执行else. 单位换算: 编码方式: ascii unicode u ...
- protobuf的Compiler卸载
一.首先,只用remove命令是不起作用的. 二.找寻到进行make的文件夹目录,然后执行make uninstall命令. 三.通过which protoc 命令,找到protoc所在位置,rm p ...