(step8.2.2)hdu 2509(Be the Winner——简单博弈)
来源:互联网 发布:淘宝 口头禅 编辑:程序博客网 时间:2024/05/17 05:54
题目大意:输入一个整数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(简单博弈)
- HDU 2509 Be The Winner ( Nim 博弈 )
- hdu 2509 Be the Winner(博弈)
- [博弈]HDU 2509 Be the Winner
- hdu 2509 Be the Winner(博弈)
- hdu 2509 Be the Winner(博弈Nim)
- HDU 2509 Be the Winner nim博弈
- HDU 2509 Be the Winner (Nim博弈)
- hdu 2509 Be the Winner(博弈Nim)
- HDU 2509 Be the Winner Nim博弈
- HDU(2509) Be the Winner /HDU(1907) John (Nim 博弈)
- HDU 2509 Be the Winner 尼姆博弈
- HDU 2509 Be the Winner(尼姆博弈)
- Be the Winner HDU杭电2509 【尼姆博弈】
- HDU-2509-Be the Winner,博弈题~~水过~~
- HDU 2509 Be the Winner (尼姆博弈)
- Be the Winner HDU-2509【Nim经典博弈】
- java包装类
- 2012-2013年度总结
- POJ 2289 - Jamie's Contact Groups 二分+最大流
- 指针常量,常量指针
- Function Pointers<外文转载>http://www.learncpp.com/cpp-tutorial/78-function-pointers/
- (step8.2.2)hdu 2509(Be the Winner——简单博弈)
- QQ 登陆
- 用EXTJS设置界面布局时有时候需要做一些较复杂的布局,同时要求布局中的各个部分能够自适应高度和宽度。
- QWidget,QMainWindow和QDialog
- Java读取properties文件
- ThinkPHP 3.1.2 输出 模型使用 配置
- utf8、iso、gbk转码总结
- No setter found for property 'packagesToScan' of class 'org.springframework.orm.hibernate3.annotatio
- OpenCV中图像不同定义类型间的转换