Game

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 50 Accepted Submission(s): 44
 
Problem Description
Bob and Alice are playing a new game. There are n boxes which have been numbered from 1 to n. Each box is either empty or contains several cards. Bob and Alice move the cards in turn. In each turn the corresponding player should choose a non-empty box A and choose another box B that B<A && (A+B)%2=1 && (A+B)%3=0. Then, take an arbitrary number (but not zero) of cards from box A to box B. The last one who can do a legal move wins. Alice is the first player. Please predict who will win the game.
 
Input
The first line contains an integer T (T<=100) indicating the number of test cases. The first line of each test case contains an integer n (1<=n<=10000). The second line has n integers which will not be bigger than 100. The i-th integer indicates the number of cards in the i-th box.
 
Output
For each test case, print the case number and the winner's name in a single line. Follow the format of the sample output.
 
Sample Input
2
2
1 2
7
1 3 3 2 2 1 2
 
Sample Output
Case 1: Alice
Case 2: Bob
 
Author
hanshuai@whu
 
Source
The 5th Guangting Cup Central China Invitational Programming Contest
 
Recommend
notonlysuccess
 
/*
题意:1到n的盒子里,是空的或者装着卡片,每人轮流移动卡片,Alice先手,移动卡片的规则:每次选择一个A,然后选择一个B
要求 B<A&&(A+B)%2==1&&(A+B)%3==0,从A中抽取任意一张卡片放到B中,谁不能移动了,就输了。 初步思路:这个就是先将能移动的盒子对找出来,然后统计能移动的牌 #错误:上面的想法不完善,只是一方面的认为卡片会从一上一级向下一级移动。 #补充:阶梯博弈,实际上卡片是在3的余数上进行转移的。 #感悟:手残用了数组,开小了,wa了两发才发现
*/
#include<bits/stdc++.h>
using namespace std;
int n;
int x;
int res=;
int t;
void init(){
res=;
}
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
init();
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&x);
if(i%==||i%==||i%==)
res^=x;
}
if(res) printf("Case %d: Alice\n",ca);
else printf("Case %d: Bob\n",ca);
}
return ;
}

随机推荐

  1. Python 接口测试(二)

    三:http状态码含义(来源于w3school): 状态码: 1xx: 信息 消息:          描述: 100 Continue   服务器仅接收到部分请求,但是一旦服务器并没有拒绝该请求,客 ...

  2. Apache Spark 2.2.0 中文文档 - 集群模式概述 | ApacheCN

    集群模式概述 该文档给出了 Spark 如何在集群上运行.使之更容易来理解所涉及到的组件的简短概述.通过阅读 应用提交指南 来学习关于在集群上启动应用. 组件 Spark 应用在集群上作为独立的进程组 ...

  3. latex使用笔记

    1.图片自动浮动到最后一页单独占用一页 将表格中的 \begin{table}[h]\end{table} 改成 \begin{table}[H]\end{table} 即可 2.公式内容中字母之间空 ...

  4. Codeforces Round #430 (Div. 2)

    A. Kirill And The Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. 使用wsimport和JAX-WS调用Web Service接口

    本文简单举例说明如何使用wsimport工具和JAX-WS API调用Web Service接口.此方法的优点:使用JDK自带的工具和API接口,无需依赖第三方库. JDK版本:1.8.0_141开发 ...

  6. Centos7下安装php7

    通过编译的方式安装php7 1. 安装PHP7 ## 下载 wget http://us2.php.net/distributions/php-7.0.2.tar.gz ## 安装 tar zxvf ...

  7. Python实战之set学习笔记及简单练习

    ['__and__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__' ...

  8. python之爬虫

    一.从网页爬下字符串清除特殊字符 import re def validateTitle(title): rstr = r"[\/\\\:\*\?\"\<\>\|\t] ...

  9. Echarts图表统计学习

    史上最全的Echarts图表学习文档 http://echarts.baidu.com/doc/doc.html 勤加练习,多做总结! http://www.stepday.com/topic/?79 ...

  10. jS判断浏览器终端

    在做移动端项目的时候,常常会遇到需要判断页面浏览终端的需求.要想判断是什么浏览器终端,先打印 navigator.userAgent 出来.所以收集了几种比较常用的方法: if(/(iPhone|iP ...