poj 3480 John 简单的nim博弈
来源:互联网 发布:opengl shader编程 编辑:程序博客网 时间:2024/06/06 05:32
John
(1) 超过1的个数为2 然后异或值!=0 先者胜,若为0则后者胜 直接按nim来
(2)超过1的个数为1个 然后先者胜
(3)超过1的个数没有,都为1的话,奇数个是后者胜,偶数时先者胜
#include<stdio.h>#include<iostream>#include<string.h>#include<math.h>int main(){ int x; scanf("%d",&x); while(x--){ int n; scanf("%d",&n); int aboveOne=0,num,tmp; scanf("%d",&num); if(num>1)aboveOne++; for(int i=2;i<=n;i++){ scanf("%d",&tmp); if(tmp>1)aboveOne++; num=num^tmp; } if(aboveOne>=2){ if(num!=0)printf("John\n"); else printf("Brother\n"); } if(aboveOne==1){ printf("John\n"); } if(aboveOne==0){ if(n%2==1)printf("Brother\n"); else printf("John\n"); } } return 0; }
- poj 3480 John 简单的nim博弈
- POJ 3480 John (Nim博弈)
- POJ 3480 John Anti-Nim博弈变形
- HDOJ 1907 John nim博弈
- HDU 1907 John Nim博弈
- HDU 1907 Nim博弈 John
- Anti-nim博弈 John poj3480
- HDOJ 1907 John (nim博弈)
- HDU 1907 John (Nim博弈)
- poj 3480 John anti-SG博弈
- (hdu 1907)John (Misère Nim,Nim博弈的变形)
- HDU 1907 John(Nim博弈)
- HDU 1907 John nim博弈变形
- HDU 1907 John (Nim博弈 模板)
- hdu 1907 John(Nim博弈)
- HDOJ 1907 John anti-nim博弈
- POJ 2975 Nim <Nim 博弈>
- [POJ](2975)Nim ---Nim博弈(博弈)
- 黑马程序员_Java中两种数组元素排序方法
- c语言地址对齐方法
- C++命名空间实现MD5加密
- Linux CentOS 系统下安装 QT
- Android应用程序组件介绍
- poj 3480 John 简单的nim博弈
- Jive源代码研究
- mysql 主从复制
- ajax验证用户登陆及记住密码
- C#操作符重载
- windows环境DLL链接问题之一:dllimport是必须的吗?
- Spring 1 IoC 2 Bean管理
- winForm用户登陆(window窗体应用程序,有改进版)
- 2013年8月28日、PS初步入门|and|Maven了解