(step8.2.2)hdu 2509(Be the Winner——简单博弈)
题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数。。。。其实理解为什么都没关系,
重要的是,理解就行。。。。)。在接下来的一行中,有n个数字,表示每个火柴堆的火柴根数。
解题思路:还是去火柴棒的问题
详细的说明请参考上一篇博客
代码如下:
/*
* 2509_1.cpp
*
* Created on: 2013年9月1日
* Author: Administrator
*/ #include <iostream> using namespace std; int main(){
int sum1;
int sum2;
int ans; int n;
while(scanf("%d",&n) != EOF){
sum1 = 0;
sum2 = 0;
ans = 0; int a[n];
int i;
for(i = 0 ; i < n ; ++i){
scanf("%d",&a[i]); if(a[i] >= 2){
sum1++;
}else{
sum2++;
} ans ^= a[i];
} if( (ans != 0 && sum1 != 0) || (ans == 0 && sum1 == 0) ){
printf("Yes\n");
}else{
printf("No\n");
}
}
}
(step8.2.2)hdu 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. 然后如果你是取的一条线上中间的苹果, 那么这一堆 ...
- HDU 2509 Be the Winner(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...
- HDU 4642 Fliping game (简单博弈)
Fliping game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 3951 Coin Game (简单博弈)
Coin Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- hdu 2999 sg函数(简单博弈)
Stone Game, Why are you always there? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/ ...
随机推荐
- 我的Fedora环境
Fedora现在也更新到了第20个版本,只是在15+以后的版本,大多数操作,都是大同小异的,也不必特意去关注版本号,只有对应到具体的软件,可能会因为库的版本,有或多或少的区别. 之前每次都喜欢按照一些 ...
- MongoDB初探系列之二:认识MongoDB提供的一些经常使用工具
在初探一中,我们已经能够顺利的将MongoDB在我们自己的机器上跑起来了. 可是在其bin文件夹以下另一些我们不熟知的工具.接下来,将介绍一下各个小工具的用途以及初探一中MongoDB在data文件夹 ...
- hdu 1085 Holding Bin-Laden Captive! (母函数)
//给你面值为1,2,5的三种硬币固定的数目,求不能凑出的最小钱数 //G(x)=(1+x+...+x^num1)(1+x^2+...+x^2num2)(1+x^5+,,,+x^5num3), //展 ...
- Django的TemplateResponse
def my_render_callback(response): return response from django.template.response import TemplateRespo ...
- SharePoint 2010 BCS - 简单实例(一)数据源加入
博客地址 http://blog.csdn.net/foxdave 本篇基于SharePoint 2010 Foundation. 我的数据库中有一个病人信息表Patient,如今我就想把这个表中的数 ...
- Html.text(转载)
2.Html.ValidationSummary:用来显示ModelState字典中所有验证错误的无序列表,使用布尔值类型参数(true)来告知辅助方法排除属性级别的错误,只显示ModelState中 ...
- VC++6.0打开文件出错的解决办法
1.下载http://support.microsoft.com/kb/241396里面的一个叫FileTool.exe的文件并解压,解压后是一个vc工程,用vc6.0打开工程,编译,得到FileTo ...
- 优酷DEMO
http://v.youku.com/v_show/id_XMTQxOTc4ODA4OA==.html http://v.youku.com/v_show/id_XMTQxOTc5MjU1Mg==.h ...
- MySQL 5.7.14 安装
http://www.cnblogs.com/zcGu/articles/5740936.html 因笔者个人需要需要在本机安装Mysql,先将安装过程记录如下,希望对他人有所参考. 一, 1, 进入 ...
- 条款20:宁以pass-by-reference-to-const替换pass-by-value
本条款的要点: 1.尽量以pass-by-reference-to-const替换pass-by-value.前者更高效且可以避免切割问题. 2.这条规则并不适用于内建类型及STL中的迭代器和函数对象 ...