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 ...
随机推荐
- solr 包地址
http://archive.apache.org/dist/lucene/solr/6.3.0/
- Hadoop的ChainMapper和ChainReducer使用案例(链式处理)(四)
不多说,直接上干货! Hadoop的MR作业支持链式处理,类似在一个生产牛奶的流水线上,每一个阶段都有特定的任务要处理,比如提供牛奶盒,装入牛奶,封盒,打印出厂日期,等等,通过这样进一步的分 ...
- Unity Mesh 初体验
什么是Mesh Mesh是Unity中的一个组件,称为网格组件.通俗的讲,Mesh是指模型的网格,3D模型是由多边形拼接而成,而一个复杂的多边形,实际上是由多个三角面拼接而成.所以一个3D模型的表面是 ...
- Eigen3的安装
- Github-Client(ANDROID)开源之旅(三) ------ 巧用ViewPagerIndicator
接上篇博文:Github-Client(ANDROID)开源之旅(二) ------ 浅析ActionBarSherkLock 文中结合了网易新闻客户端讲解了开源库ActionBarSherklock ...
- Excel数据导入SQL Server
基本有2种方案,都是无需安装Office的方案 Ole DB读取 + BulkCopy 获取Excel各个SheetName //连接串 string strConn = "Provider ...
- 记 thoughtworks 的一次面试
2015年的1月30号,星期五.我将要去thoughtworks面试. 最早听说thoughtworks是在学校听同学说起的.一句不经意间的引导可能会改变我的整个人生. 实话说,我之前对thought ...
- springboot的多个配置文件的关系
一般我们在使用springboot时会用到多个环境下的配置文件,例如 application-dev.yml:开发环境 application-uat.yml:用户验收测试环境 application ...
- Elasticsearch插件清单
1.API插件:主要对Elasticsearch添加的API特性或者功能,通常用于搜索或者映射 2. 报警插件: 当Elasticsearch的索引指标超过阀值时就会触发 3. 分词插件:ik是比较好 ...
- 在Oracle用SQL处理以 System.currentTimeMillis
有時為了系統的需求會紀錄到毫秒(Millisecond),我們會接將得到的值寫入db,但是如果要用SQL 做時間範圍的搜尋,有以下做法( systemdate欄位存放System.currentTim ...