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. Spring Boot Document Part II(下)

    Part II. Getting started 11. 开发第一个Spirng Boot Application使用Spring Boot的关键特征开发一个基于JAVA Web的“Hello Wor ...

  2. php中常用的字符串比较函数strcmp()实例解释

    int strcmp ( string $str1 , string $str2 ) 以二进制方式进行比较以该函数比较时区分大小写返回值,如果str1小于str2返回<0,如果str1大于str ...

  3. 为什么说程序员都应该玩一玩GitHub

    既熟悉又陌生的GitHub 关于GitHub,相信每一个程序员都再熟悉不过了.它为开发者提供Git仓库的托管服务,是全世界最大的代码集中地,被戏称为“全球最大同性交友网站”. 但是对于很大一部分程序员 ...

  4. XSS跨站脚步攻击及防范

    XSS(Cross Site Script)跨站脚本攻击.它指的是恶意攻击者往Web 页面里插入恶 意html 代码,当用户浏览该页之时,嵌入其中Web 里面的html 代码会被执行,从而达到侵害用户 ...

  5. spring <context:annotation-config> 跟 <context:component-scan>诠释及区别

    <context:annotation-config> 和 <context:component-scan>的区别 Difference between <context ...

  6. ABP增删改查代码片段

    @using System.Web.Optimization @using MultiPageSimpleTask.Entitys.Dtos; @model IList<ProductDto&g ...

  7. 设置MySQL最大连接数

    <pre name="code" class="sql">在使用MySQL数据库的时候,经常会遇到这么一个问题,就是"Can not co ...

  8. MySQL主从复制 + Mycat实现读写分离

    说明:两台MySQL服务器都是使用CentOS6.5系统,MySQL版本为mysql-5.7.17 MySQL一主一被实现主从复制 注意:写包括insert,delete,update 操作:读只有s ...

  9. GooglePlay - 排行榜及支付接入

    前言 Google Play应用商店在国外Android市场中地位基本与AppStore在IOS中的地位一致,为此考虑国外的应用时,Android首要考虑的是接入GooglePlay的排行榜等支持. ...

  10. spring容器启动扩展

    我们可以在spring容器启动时添加自己的定制化初始化工作. 1)具体方法为:在web.xml中配置初始化属性contextInitializerClasses的值例如: <context-pa ...