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. oracle pl/sql 简介

    一.pl/sql 是什么pl/sql(procedural language/sql)是oracle在标准的sql语言上的扩展.pl/sql不仅允许嵌入sql语言,还可以定义变量和常量,允许使用条件语 ...

  2. Suneast & Daxia (规律)

    Suneast & Daxia Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u ...

  3. git添加比较和合并工具(meld)

    git 下的(difftool)和(mergetool)是专门提供给使用者用自己的工具进行diff和merge的命令: # git config --global diff.tool meld # g ...

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

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

  5. apache一个IP一个端口对应多个域名

    一个IP一个端口对应多个域名: NameVirtualHost XXX.XXX.XXX.XXX:80 <VirtualHost XXX.XXX.XXX.XXX:80> ServerAdmi ...

  6. IIS7中JS、CSS、Image无法显示和加载解决方案

    前两天把机器从Windows7升级到Windows10,IIS也跟着升级了,在获取项目搭载IIS上发现原有的页面中所有的JS.CSS.Image都无法访问,提示500错误,起初以为是IIS没有装好 重 ...

  7. Python实战之实现简单的购物车系统

    #!usr/bin/env Python3 # -*-coding:utf-8-*- # 程序:购物车程序 # # 需求: # # 启动程序后,让用户输入工资,然后打印商品列表 # 允许用户根据商品编 ...

  8. webpack2使用ch3-自动化生成.html和内部引入的js自动更改

    1 安装webpack插件 $ cnpm install html-webpack-plugin --save-dev 安装成功后 2 由于之前 dist/目录下,编译后的.html和.js会混在一起 ...

  9. webpack2使用ch2-entry和output简要说明

    1 entry打包入口 打包字符串和数组 const webpack = require('webpack'), path = require('path'); module.exports = { ...

  10. WPF通过代码动态的加载样式

    tabitem.SetResourceReference(TabItem.StyleProperty, "mainTabItemStyle"); tabitem.Content = ...