Light OJ 1253 Misere Nim (尼姆博弈(2))
LightOJ1253 :Misere Nim
Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, each pile containing one or more stones. The players alternate turns and in each turn a player can select one of the piles and can remove as many stones from that pile unless the pile is empty. In each turn a player must remove at least one stone from any pile. Alice starts first. The player who removes the last stone loses the game.
Input starts with an integer T (≤ 200), denoting the number of test cases.
Each case starts with a line containing an integer k (1 ≤ k ≤ 100). The next line contains k space separated integers denoting the number of stones in each pile. The number of stones in a pile lies in the range [1, 109].
For each case, print the case number and 'Alice' if Alice wins otherwise print 'Bob'.
3
4
2 3 4 5
5
1 1 2 4 10
1
1
Case 1: Bob
Case 2: Alice
Case 3: Bob
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int i,n,t,k,data,ans,chongyu,cas=;
cin>>t;
while(t--)
{
cin>>k;
chongyu=ans=;
for(i=;i<k;i++)
{
cin>>data;
if(data>)
chongyu++;
ans^=data;
}
if((ans&&chongyu)||(!ans&&!chongyu)) //s1,s2,t0
printf("Case %d: Alice\n",cas++);
else
printf("Case %d: Bob\n",cas++);
}
return ;
}
最新文章
- 【Codeforces 738D】Sea Battle(贪心)
- 2016春招Android开发实习生(网易传媒)笔试
- spring中各jar功能及jar包之间的依赖关系
- Redis 笔记与总结6 Redis 高级应用之 事务处理、持久化操作、pub_sub、虚拟内存
- 在eclipse.ini中指定jdk的方式
- android application类的用法
- [原]Unity3D深入浅出 - GUI控件
- 用grunt搭建自动化的web前端开发环境-完整教程
- Maven 安装记
- Git学习04 --分支管理
- Node.js 小工具--supervisor
- Cow Acrobats(贪心)
- 运行safari提示:无法启动此程序,因为计算机中丢失 QTCF.dll
- 四步安装typecho(LNMP环境)
- SparkSteaming运行流程分析以及CheckPoint操作
- 关于if判断和switch
- 使用gitblit搭建git服务器
- 总结:JDK1.5-JDK1.8各个新特性
- Dom4j向XML中指定位置添加、删除、修改节点——(五)
- from __future__ import
热门文章
- NOI题库--砝码称重V2(多重背包2^n拆分)
- 【bzoj3246】 Ioi2013—Dreaming
- CVE-2014-6321 &;&; MS14-066 Microsoft Schannel Remote Code Execution Vulnerability Analysis
- Android学习笔记02-Mac下编译java代码
- P1049送给圣诞夜的礼品(矩阵十大问题之四)
- Java初学(五)
- 根据某列,将两个 dataframe 合并
- JS实现打字机式字符输出效果
- linux tail命令的使用方法详解(转)
- SVN服务器搭建--Subversio与TortoiseSVN的配置安装