Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more than half stones from that pile. So, for example if a pile contains 10 stones, then a player can take at least 1 and at most 5 stones from that pile. If a pile contains 7 stones; at most 3 stones from that pile can be removed.

Both Alice and Bob play perfectly. The player who cannot make a valid move loses. Now you are given the information of the piles and the number of stones in all the piles, you have to find the player who will win if both play optimally.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer n (1 ≤ n ≤ 1000). The next line contains n space separated integers ranging in [1, 109]. The ith integer in this line denotes the number of stones in the ith pile.

Output

For each case, print the case number and the name of the player who will win the game.

Sample Input

5

1

1

3

10 11 12

5

1 2 3 4 5

2

4 9

3

1 3 9

Sample Output

Case 1: Bob

Case 2: Alice

Case 3: Alice

Case 4: Bob

Case 5: Alice

/*
* @Author: lyuc
* @Date: 2017-04-26 21:32:51
* @Last Modified by: lyuc
* @Last Modified time: 2017-04-26 22:13:13
*/ /*题意:给你n堆石子每次你可以选择一堆,至少取一个,最多不能超过一半,比如7个的时候,你最多取3个谁不
* 能取了就输了
*
*初步思路:想到了SG,但是没办法数据量太大了,只能打表找规律,找到规律,如果n为奇数sg(n)=sg(n/2)
* 如果是偶数sg(n)=n/2
*/
#include <bits/stdc++.h>
using namespace std;
int t,n;
int num;
int sg[];
int hash[];
int res;
//sg打表
void init(){
memset(sg,,sizeof sg);
for(int i=;i<;i++){
memset(hash,,sizeof hash);
for(int j=;j+j<=i;j++){
hash[sg[i-j]]=;
}
for(int j=;j<;j++){
if(hash[j]==){
sg[i]=j;
break;
}
}
}
}
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
printf("Case %d: ",ca);
res=;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&num);
while(num%!=){
num/=;
}
res^=num;
}
printf(res==?"Bob\n":"Alice\n");
}
return ;
}

Again Stone Game的更多相关文章

  1. POJ1740A New Stone Game[组合游戏]

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5769   Accepted: 3158 ...

  2. timus 1180. Stone Game 解题报告

    1.题目: 1180. Stone Game Time limit: 1.0 secondMemory limit: 64 MB Two Nikifors play a funny game. The ...

  3. HDU 4048 Zhuge Liang's Stone Sentinel Maze

    Zhuge Liang's Stone Sentinel Maze Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/327 ...

  4. POJ 1740 A New Stone Game

    A New Stone Game Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5453   Accepted: 2989 ...

  5. Light OJ 1296 - Again Stone Game (博弈sg函数递推)

    F - Again Stone Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu ...

  6. poj 1115 Lifting the Stone 计算多边形的中心

    Lifting the Stone Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. 【POJ】A New Stone Game(博弈论)

    http://poj.org/problem?id=1740 题目大意就是,对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分 ...

  8. HDUOJ--------A simple stone game(尼姆博弈扩展)(2008北京现场赛A题)

    A simple stone game                                                                                  ...

  9. POJ 1740 A New Stone Game(普通博弈)

    A New Stone Game 题意: 对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该堆剩余石子的一部分分给其它的某些堆.最后谁无子可取即输 ...

  10. POJ 3922A Simple Stone Game

    题目链接 A Sample Stone Game 题目大意:给定n,k,表示最初时有n个石头,两个人玩取石子游戏,第一个人第一次可以取1~n-1个石头,后面每个人最多可以拿走前面一个人拿走的个数的K倍 ...

随机推荐

  1. LeetCode解题中位运算的运用

    位运算是我最近才开始重视的东西,因为在LeetCode上面刷题的时候发现很多题目使用位运算会快很多.位运算的使用包含着许多技巧(详细可以参考http://blog.csdn.net/zmazon/ar ...

  2. ng-transclude

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. IDEA- idea代码调试debug

    IDEA有很多的快捷键,下面整理Debug的快捷键,方便自己使用!(阅读本篇可能花费您2分钟,需要多的实践练习) F9 resume programe 恢复程序 Alt+F10 show execut ...

  4. WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系

    WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系: 1.Canvas/WrapPanel控件: 其子控件的HorizontalAlign ...

  5. S2_OOP第二章

    第一章 继承 语法 修饰符 子类 extends 父类{ //类定义不封 } 使用extends继承父类的属性和方法.使用super关键字调用父类的方法. 概念 继承是面向对象的三大特特之一,Java ...

  6. 在Ubuntu终端彻底删除软件

    在Ubuntu终端彻底删除软件 1.删除软件 方法一.如果你知道要删除软件的具体名称,可以使用 sudo apt-get remove --purge 软件名称 sudo apt-get autore ...

  7. Angular JS中的路由

      前  言            本章节将为大家介绍 AngularJS 路由.AngularJS 路由允许我们通过不同的 URL 访问不同的内容.通过 AngularJS 可以实现多视图的单页We ...

  8. Jmeter脚本调试——关联(正则表达式)

    关联,在脚本中,是必应用到的一个设置方法,将脚本中,每次都会动态变化的特殊值进行关联.一个能正确执行的脚本,都需要进行关联(LR.jmeter). Jmeter关联: 在脚本回放过程中,客户端发出请求 ...

  9. FPGA与安防领域

    安防主要包括:闭路监控系统.防盗报警系统.楼宇对讲系统.停车厂管理系统.小区一卡通系统.红外周界报警系统.电子围栏.巡更系统.考勤门禁系统.安防机房系统.电子考场系统.智能门锁等等. 在监控系统中,F ...

  10. 从头编写 asp.net core 2.0 web api 基础框架 (4) EF配置

    第1部分:http://www.cnblogs.com/cgzl/p/7637250.html 第2部分:http://www.cnblogs.com/cgzl/p/7640077.html 第3部分 ...