HDU 1907 —— John
来源:互联网 发布:程序员私活 编辑:程序博客网 时间:2024/05/17 20:29
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1907
题意:取法和Nim游戏一样,但是最后拿完的那个人是loser;
思路:需要考虑特殊情况 —— 最开始每堆的个数都为1,这个时候对堆数进行奇偶判断;
#include<iostream>using namespace std;const int maxn = 50;int cas, n;int a[maxn];int main(){ cin>>cas; while(cas--){ cin>>n; int x = 0; int cnt = 0; for(int i = 0;i<n;i++){ cin>>a[i]; if(a[i] == 1) cnt++; x = x^a[i]; } if(cnt == n){ if(n%2 == 0) cout<<"John"<<endl; else cout<<"Brother"<<endl; continue; } if(x == 0) cout<<"Brother"<<endl; else cout<<"John"<<endl; } return 0;}
0 0
- HDU 1907 —— John
- (step8.2.1)hdu 1907(John ——博弈)
- John(HDU 1907) —— 尼姆博弈
- HDU 1907 John
- hdu 1907 John
- HDU 1907 - John
- hdu 1907 John
- Hdu 1907 John
- HDU 1907 John
- HDU 1907 John 尼姆博奕
- [博弈]HDU 1907 John
- John(hdu 1907 2509)
- HDU-1907 John
- hdu 1907 John
- hdu 1907 John
- hdu 1907 John
- John - HDU 1907 博弈论
- HDU 1907 John
- NN远程桌面SDK之Delphi开发源码
- Unity——VR分屏关于UGUI的摆放,UI如何放进vr分屏中
- idea git
- c# Adapter 获取sql语句
- ORA-15040: diskgroup is incomplete 报错分析
- HDU 1907 —— John
- string中与tchar转换
- R原因列联表table()函数
- Linux系统下配置eclipse和android studio的安卓开发环境,以ubutun为例实战篇
- 日志框架统一输出控制(slf4j+log4j)
- Lua - 17
- 建立三个线程,A线程打印10次A,B线程打印10次B,C线程打印10次C,要求线程同时运行,交替打印10次ABC。
- Hbuilder egit插件使用(二)
- js验证电话号码和身份证号