LightOJ1253 :Misere Nim

时间限制:1000MS    内存限制:32768KByte   64位IO格式:%lld & %llu
描述

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

题目来源
Problem Setter: Jane Alam Jan 
 
题意
k堆石子,每堆个数不定,每次取一堆中的任意个,谁取到最后一个谁输。
题解
详见上篇博客 尼姆博弈 s1,s2,t0为必胜态。
#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 ;
}
 

最新文章

  1. 【Codeforces 738D】Sea Battle(贪心)
  2. 2016春招Android开发实习生(网易传媒)笔试
  3. spring中各jar功能及jar包之间的依赖关系
  4. Redis 笔记与总结6 Redis 高级应用之 事务处理、持久化操作、pub_sub、虚拟内存
  5. 在eclipse.ini中指定jdk的方式
  6. android application类的用法
  7. [原]Unity3D深入浅出 - GUI控件
  8. 用grunt搭建自动化的web前端开发环境-完整教程
  9. Maven 安装记
  10. Git学习04 --分支管理
  11. Node.js 小工具--supervisor
  12. Cow Acrobats(贪心)
  13. 运行safari提示:无法启动此程序,因为计算机中丢失 QTCF.dll
  14. 四步安装typecho(LNMP环境)
  15. SparkSteaming运行流程分析以及CheckPoint操作
  16. 关于if判断和switch
  17. 使用gitblit搭建git服务器
  18. 总结:JDK1.5-JDK1.8各个新特性
  19. Dom4j向XML中指定位置添加、删除、修改节点——(五)
  20. from __future__ import

热门文章

  1. NOI题库--砝码称重V2(多重背包2^n拆分)
  2. 【bzoj3246】 Ioi2013—Dreaming
  3. CVE-2014-6321 &amp;&amp; MS14-066 Microsoft Schannel Remote Code Execution Vulnerability Analysis
  4. Android学习笔记02-Mac下编译java代码
  5. P1049送给圣诞夜的礼品(矩阵十大问题之四)
  6. Java初学(五)
  7. 根据某列,将两个 dataframe 合并
  8. JS实现打字机式字符输出效果
  9. linux tail命令的使用方法详解(转)
  10. SVN服务器搭建--Subversio与TortoiseSVN的配置安装