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. struts1.3整合spring2.5(将spring委托给struts方式)

    前提是配置完struts1.3 导包 spring-2.5.6.jar //spring核心包 spring-webmvc-struts-2.5.5.jar //struts整合spring使用 lo ...

  2. Opengl4.5 中文手册—B

    索引 A      B    C      D     E     F     G H      I     J      K     L     M     N O      P    Q      ...

  3. NOIP2017SummerTraining0710

    个人感受:这套题,题目泄露,没什么好打的,第一题刚开始题目理解错误,后来还行,第二道题,打了一个50还是60分的dp,第三道暴力过了小数据,拿了200分,排名15+. 问题 A: 七天使的通讯 时间限 ...

  4. OpenCV中的绘图函数-OpenCV步步精深

    OpenCV 中的绘图函数 画线 首先要为画的线创造出环境,就要生成一个空的黑底图像 img=np.zeros((512,512,3), np.uint8) 这是黑色的底,我们的画布,我把窗口名叫做i ...

  5. jQuery form插件使用详解

    点击打开: jquery选择器全解 jquery中的style样式操作 jquery中的DOM操作 jquery中的事件操作全解 jquery中的动画操作全解 jquery中ajax的应用 自定义jq ...

  6. 运用 finereport 和 oracle 结合开发报表思路大总结

    近排自己学习了一款软件finereport开发报表模块,自己总结了如何了解需求,分析需求,再进行实践应用开发,最后进行测试数据的准确性,部署报表到项目对应的模块中显示. 一.需求(根据需求文档分析) ...

  7. [Python]Codecombat攻略之远边的森林Forest(1-40关)

    首页:https://cn.codecombat.com/play语言:Python 第二界面:远边的森林Forest(40关)时间:2-6小时内容:if/else.关系操作符.对象属性.处理输入网页 ...

  8. Intel Core Microarchitecture Pipeline

    Intel微处理器近20年从Pentium发展到Skylake,得益于制作工艺上的巨大发展,处理器的性能得到了非常大的增强,功能模块增多,不过其指令处理pipeline的主干部分算不上有特别大的变化, ...

  9. jquery各种事件使用方法总结(from:天宇之游)

    ps:本博客转自博主  天宇之游 ,地址:http://www.cnblogs.com/cwp-bg/  ,再次感谢天宇之游.jquery事件使用方法总结 一.鼠标事件1. click():鼠标单击事 ...

  10. [scrapy]使用Anaconda来搭建scrapy的运行环境。官方推荐方法。

    1.官方文档推荐. 2.一般情况下多数人使用框架的时候使用的是,安装pywin32,和openssl来搭建scrapy的运行环境.但是由于,在这样搭建环境中会遇到各种各样的问题,诸如:下载的版本有问题 ...