HDU 1907 John ( Nim Game )
来源:互联网 发布:完美解码播放器 mac 编辑:程序博客网 时间:2024/05/15 04:46
就是很白的Nim博弈,没有什么可说的
但是我交了有6次才过
这道题是最后一个拿走的人是输的人,情况和最后拿走的人赢的不同
总结一下要注意的:第一就是要判断是S态还是T态 ; 第二就是要判断是S0状态还是T2状态,是的话就是必输的
代码如下:
#include <cstdio>int T, n, x, ans, s0, t2;int main(){ scanf("%d", &T); while ( T-- ) { s0 = t2 = 0; scanf("%d", &n); scanf("%d", &ans); if ( ans > 1 ) t2++; else if ( ans == 1 ) s0++; for ( int i = 1; i < n; ++i ) { scanf("%d", &x); ans ^= x; if ( x == 1 ) s0++; else if ( x > 1 ) t2++; } if ( s0 == n && ans != 0 && s0 % 2 == 1 ) printf("Brother\n"); else if ( t2 >= 2 && ans == 0 ) printf("Brother\n"); else printf("John\n"); } }
- HDU 1907 John ( Nim Game )
- HDU 1907 John(Nim game)
- HDU 1907 John Nim博弈
- hdu 1907 John(anti-nim)
- HDU 1907 Nim博弈 John
- HDU 1907 John (Nim博弈)
- HDU 1907 John(Nim博弈)
- HDU 1907 John nim博弈变形
- HDU 1907 John (Nim博弈 模板)
- hdu 1907 John(Nim博弈)
- hdu 1907 John,hdu 2509 Be the Winner anti-NIM
- HDU(2509) Be the Winner /HDU(1907) John (Nim 博弈)
- HDU 1907 John(Nim游戏 取完为输)
- hdu 1907 John(组合游戏 NIM变形)@
- hdu 1850 nim game
- (hdu 1907)John (Misère Nim,Nim博弈的变形)
- HDOJ 1907 John nim博弈
- HDOJ 1907 John (nim博弈)
- 开篇-模式和原则
- My Eclipse 生成序列号
- Javascript入门系列:JS简介
- qsort函数用法
- Matlab图像处理相关函数命令大全
- HDU 1907 John ( Nim Game )
- 探索Lua5.2内部实现:Garbage Collection(2)
- Uva-11462-Age Sort
- IT与读研
- Fedora10下源码编译vlc-1.1.1 流程及注意事项
- 整理一个EOE的JNI实例讲解
- Linux中查看文件编码
- myeclipse当你点击左边的项目框后再次点击右边出现的Unhandled event loop exception
- 剖析程序的内存布局