首页 技术 正文
技术 2022年11月12日
0 收藏 381 点赞 4,457 浏览 1185 个字

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 ;
}

 

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,022
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,359
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,142
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,773
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,851