(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/ ...
随机推荐
- MyEclipse 8.5整合Git,并在Github上发布项目(转)
下载Eclipse的git插件——EGit.下载网址http://download.eclipse.org/egit/updates-1.3/org.eclipse.egit-updatesite-1 ...
- SharePoint 2010以其他用户身份登录的弹出代码
在SharePoint 2010平台中,可以在当前用户登录系统的情况下使用其他用户身份登录,以达到在同一浏览器中切换用户身份的目的. 每个用户登录SharePoint系统之后都会在系统右上角将用户的名 ...
- exists
select count(*) from Table_A where exists (select count(*) from Table_B.Column1 = Table_A.Column1) 该 ...
- 使用jsonEditor打造一个复杂json编辑器
最近研究一个web版的json编辑器,在github中搜索,发现了这个利器. https://github.com/jdorn/json-editor 几经研究,终于把该控件的大部分功能研究透彻. 发 ...
- Reverse Integer - Palindrome Number - 简单模拟
第一个题目是将整数进行反转,这个题实现反转并不难,主要关键点在于如何进行溢出判断.溢出判断再上一篇字符串转整数中已有介绍,本题采用其中的第三种方法,将数字转为字符串,使用字符串比较大小的方法进行比较. ...
- BZOJ 3675: [Apio2014]序列分割( dp + 斜率优化 )
WA了一版... 切点确定的话, 顺序是不会影响结果的..所以可以dp dp(i, k) = max(dp(j, k-1) + (sumn - sumi) * (sumi - sumj)) 然后斜率优 ...
- Nginx 之四: Nginx服务器的压缩功能和缓存功能
在Nginx服务器配置文件中可以通过配置Gzip的使用,可以配置在http块,server 块或者location块中设置,Nginx服务器可以通过ngx_http_gzip_module模块.ngx ...
- 我的Python成长之路---第六天---Python基础(19)---2016年2月20日(晴)
shelve模块 shelve模块是pickle模块的扩展,可以通过key,value的方式访问pickle持久化保存的数据 持久化保存: 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
- nfs:server is not responding,still trying 原因与解决
方案(学自他人) nfs:server is not responding,still trying的解决方法 (2009-04-20 10:20) 方法1 : 我在arm上通过NFS共享文件时出现下 ...
- Socket 基础解析使用ServerSocket建立聊天服务器
很简单的教程哦! 1.socket 简介 Socket 又称"套接字",应用程序通常通过"套接字"向网络发出请求或者应答网络请求.ServerSocket 用于 ...