尼姆博弈HDU1907
HDU1907 http://acm.hdu.edu.cn/showproblem.php?pid=1907
两种情况1.当全是1时,要看堆数的奇偶性
2.判断是奇异局势还是非奇异局势
代码:
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int m,n;
cin>>n;
while(n--)
{
int temp=;
int ans=;
int a[];
cin>>m;
for(int i=; i<m; i++)
{
cin>>a[i];
ans^=a[i];
if(a[i]>)
temp=;
} if(temp==)
{
if(m%==)
{
cout<<"John"<<endl; }
else
{
cout<<"Brother"<<endl; }
}
else
{ if(ans==)
{
cout<<"Brother"<<endl;
}
else
cout<<"John"<<endl; }
}
}
尼姆博弈HDU1907的更多相关文章
- HDU1907(尼姆博弈)
John Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- hdu1907 尼姆博弈
尼姆博弈的性质. 最后一个取输.若a1^a2^a3...^a4=0表示利他态T,不然为利己态S.充裕堆:1个堆里的个数大于2.T2表示充裕堆大于等于2,T1表示充裕堆大于等于1,T0表示无充裕堆.S2 ...
- hdu----(1849)Rabbit and Grass(简单的尼姆博弈)
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1849(Rabbit and Grass) 尼姆博弈
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Being a Good Boy in Spring Festival 尼姆博弈
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Descr ...
- HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)
Climbing the Hill Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Su ...
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- Light OJ 1253 Misere Nim (尼姆博弈(2))
LightOJ1253 :Misere Nim 时间限制:1000MS 内存限制:32768KByte 64位IO格式:%lld & %llu 描述 Alice and Bob ar ...
随机推荐
- discuz!3 二次开发C#学者
PHP入门,从搞数据库开始: 大致看了以下PHP还是很简单的 比如链接数据库,就这么几行,比asp.net简单的多,就是需要自己搞数据的显示,需要精通HTML和代码生成技术: <?php $co ...
- HackerRank "Dorsey Thief"
A variation to 0-1 Knapsack. (No Python code got fully AC. Python is too slow for this problem) #inc ...
- 剑指offer系列61---数组中的逆序对
[题目]在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求出这个数组中的逆序对的总数. * [思路]运用归并排序的思想. * 首先将数组分成两个子数组,统 ...
- SDC文件模版
# 1. Define clock create_clock -name "clk_in" -period 20ns [get_ports {clk_in}] # 2. tco c ...
- grep,sed,cut,awk,join个性特点
grep 从数据文件中查询/提取出含有特定关键字的行. sed 主要用于对数据文件中特定字符串的替换处理. cut 按照指定的分隔符(-d)剪下选定的列(-f num)或者字符(-c)的内容. awk ...
- C# Winform中WndProc 函数作用
http://blog.csdn.net/xochenlin/article/details/4328954 C# Winform中WndProc 函数作用: 主要用在拦截并处理系统消息和自定义消息 ...
- (C/C++ )Interview in English - Virtual
Q: What is virtual function?A: A virtual function or virtual method is a function or method whose be ...
- Coding 初级教程(二)——上传已有项目
Coding 初级教程(二)——上传已有项目 [摘要:方针读者 :已具有 Coding.net 的账号. 本文首要先容若何把项目上传到 Coding.net 上. 分两种环境,一种是项目已归入到 gi ...
- Android之访问下载文件
1.SD卡操作类 FileUtils.java package com.example.mars_1500_download; import java.io.File; import java.io. ...
- IceGrid负载均衡部署 z
[IceGrid负载均衡部署步骤]1.环境主机1:IP=192.168.0.239,上面部署注册表服务器registry和节点node1,registry和node1运行在同一进程中:主机2:IP=1 ...