John
来源:互联网 发布:网络电视腾讯 编辑:程序博客网 时间:2024/04/30 01:45
Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so on. Please note that each player has to eat at least one M&M during his turn. If John (or his brother) will eat the last M&M from the box he will be considered as a looser and he will have to buy a new candy box.
Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.
Both of players are using optimal game strategy. John starts first always. You will be given information about M&Ms and your task is to determine a winner of such a beautiful game.
Constraints:
1 <= T <= 474,
1 <= N <= 47,
1 <= Ai <= 4747
233 5 111
JohnBrother
先手胜当且仅当
(1)所有堆石子数都为1且游戏的SG值为0 ,(2)存在某堆石子数大于1且游戏的SG值不为0
(1)若所有堆石子数都为1且SG值为0,则共有偶数堆石子,故先手胜。
(2)
i)只有一堆石子数大于1时,我们总可以对该堆石子操作,使操作后石子堆数为奇数且所有堆得石子数均为1
ii)有超过一堆石子数大于1时,先手将SG值变为0即可,且总还存在某堆石子数大于1
代码:
代码:
#include<stdio.h>#include<String.h>using namespace std;int main(){int T;scanf("%d",&T);while(T--){int n;scanf("%d",&n);int flag=0;int ans=0;for(int i=0;i<n;i++){int a;scanf("%d",&a);flag^=a;if(a>1) ans=1;}if(flag&&!ans||!flag&&ans) printf("Brother\n");else printf("John\n");}return 0;}
阅读全文
0 0
- John
- John
- John
- John
- John Carmack
- 《John Q》
- John感悟
- John感悟
- 【HDU1097】John
- HDU1907-John
- hdu1907 John
- John Keats
- 【poj3480】John
- hdu1907 John
- 1907 John
- hdu1907 John
- Professor John
- 关于John Carmack
- ubuntu 同时使用无线网卡和有线网卡
- Dynamo-Amzaon's Highly Available Key-value Store阅读笔记
- 1701H211.22 王建瑜 连续第三天
- ssm框架
- Python 之禅(╯‵□′)╯︵┻━┻ 怕不是有毒吧
- John
- [基础题] 3、设计一个交通工具抽象类,提供抽象方法--驾驶
- 【Scikit-Learn 中文文档】支持向量机
- FFmpeg读取摄像头用OpenCV显示
- Java用WebSocket + tail命令实现Web实时日志(转)
- mysql解决datetime与timestamp精确到毫秒的问题
- NOIP2017提高组D2
- 狄利克雷分布
- 【Scikit-Learn 中文文档】随机梯度下降