Hdu 1907(博弈)
2016-01-11 10:43
344 查看
题目地址
http://acm.hdu.edu.cn/showproblem.php?pid=1907
分析:取火柴游戏的一种类型
分析必胜态和必输态便可
必胜态:S1,S1,T0
必输态:S0,T2
http://acm.hdu.edu.cn/showproblem.php?pid=1907
分析:取火柴游戏的一种类型
分析必胜态和必输态便可
必胜态:S1,S1,T0
必输态:S0,T2
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; int main() { int a[5000]; int ans;//异或 int s1,s2;//s1为充裕堆,s2为孤单堆 int T; cin>>T; while (T--) { s1=s2=0;//注意初始化 ans=0; int n; scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d",&a[i]); if (a[i]>=2) s1++; else s2++; ans^=a[i]; } if( ans!=0 && s1!=0 || ans==0 && s1==0) printf("John\n"); if((ans==0 && s1>=2) || (ans!=0 && s2%2!=0 && s1==0)) printf("Brother\n"); } return 0; }
相关文章推荐
- 解决 ubuntu KDE桌面环境下Eclipse新建项目闪退问题
- Latex 表格内文字过长自动换行
- 小范围排序
- 注解形式开发Controller方法的返回值类型
- win7的目录和vbox的共享,linux中没有权限打开
- java内存计算
- Jmter相关组件用法
- ABAP 使用向导创建TABLE CONTROL (TC 表控件)
- 进退法例子
- Java中的Abstract关键字的使用注意点
- iOS性能优化之内存管理:Analyze、Leaks、Allocations的使用和案例代码
- 分享一下我封装iOS自定义控件的体会,附上三个好用的控件Demo &lt;时间选择器&amp;多行输入框&amp;日期选择器&gt;
- 仿照微信的效果,实现了一个支持多选、选原图和视频的图片选择器,适配了iOS6-9系统,3行代码即可集成.
- GET POST 区别详解
- 基于HTML5 SVG和Raphaël.js的混合图标动画特效插件教程
- Mysql 安全管理
- rocketmq
- WEB压测工具之siege
- c语言swap函数总结
- 眉目传情之匠心独运的kfifo