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 |
Sample Output
Case 1: Alice |
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 ;
}
随机推荐
-
C++ cast
excerpted from Type conversions K&R Section 2.7 p59 对type conversion 的解释: The precise meaning of ...
-
gulp 插件
原文链接:http://www.mamicode.com/info-detail-517085.html gulp是什么? http://gulpjs.com/ 相信你会明白的! 与著名的构建工具gr ...
-
关于VS快捷键的使用总结
首先快捷键是为了快,不能为了用快捷键而用快捷键. 既然说到快,我个人认为要涉及到一个使用频率问题,如果一个功能的快捷键使用频率极高,那么就应该把它调到触手可及的位置, 如:经常看别人源代码,经常会使用 ...
-
AX2009按照批次生产日期预留
AX2009如果想按照批处理号预留,它默认是按照InventBatchId排序的,但并不是InventBatchd小的批次的生产日期就早,所以这个逻辑得改一下,让它按照InventBatch的Prod ...
-
网站常用css必备css reset
在我们写前端代码页面的时候,很多常用的CSS类都是固定的!但没有一个标准或者大家都按自己的方式去随意的写,这样就每次都重复写一些固定的类! 为此HTML5 Doctor(HTML5医生)为我们总结了一 ...
-
132. Palindrome Partitioning II
题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return ...
-
Android获取IMSI和IMEI
IMSI是一个 唯一的数字, 标识了GSM和UMTS 网络里的唯一一个用户. 它 存储 在手机的SIM卡里,它会通过手机发送到网络上. IMEI也是一串唯一的数字, 标识了 GSM 和 UMTS网络里 ...
-
Altium Designer 等长线&;&;蛇形线
Altium Designer 里面怎么画等长线 (1)一般是将走线布完后,新建一个class. Design -> Classes 如上图添加完后可以点击close. (2)快捷键 T + R ...
-
html5 WebSocket 与 PHP socket 聊天室原理
html js <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
-
nginx时间设置解析函数
https://trac.nginx.org/nginx/browser/nginx/src/core/ngx_parse.c /* * Copyright (C) Igor Sysoev * Cop ...