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
根据staircase nim游戏的结论
假设移动的终点为0,那么只要考虑奇数位的Nim和就行了
如果不是按位移动的,那么就变成距离终点步数为奇数的Nim和
画图归纳,发现当i%6等于0,2,5时,到终点步数为奇数
取那些位的Nim和
 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int ans,n;
int gi()
{
int x=;char ch=getchar();
while (ch<''||ch>'') ch=getchar();
while (ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x;
}
int main()
{int i,T,TT,x;
cin>>T;
TT=T;
while (T--)
{
cin>>n;
ans=;
for (i=;i<=n;i++)
{
x=gi();
if (i%==||i%==||i%==)
ans^=x;
}
if (ans) printf("Case %d: Alice\n",TT-T);
else printf("Case %d: Bob\n",TT-T);
}
}
 

HDU3389 Game的更多相关文章

随机推荐

  1. JavaScript(第十三天)【内置对象】

    学习要点: 1.Global对象 2.Math对象 ECMA-262对内置对象的定义是:"由ECMAScript实现提供的.不依赖宿主环境的对象,这些对象在ECMAScript程序执行之前就 ...

  2. 咸鱼翻身beta冲刺博客集

    咸鱼翻身beta冲刺博客集 凡事预则立-于Beta冲刺前 beta冲刺1-咸鱼 beta冲刺2-咸鱼 beta冲刺3-咸鱼 beta冲刺4-咸鱼 beta冲刺5-咸鱼 beta冲刺6-咸鱼 beta冲 ...

  3. 2017-2018-1 1623 bug终结者 冲刺007

    bug终结者 冲刺007 by 20162302 杨京典 今日任务:排行榜界面 排行榜界面,选项界面 简要说明 排行榜界面用于展示用户通关是所使用的步数和时间,选项界面可以调整背景音乐的开关.选择砖块 ...

  4. Spring Boot jar包linux服务器部署

    Spring Boot 部署 一.使用命令行java -jar 常驻 nohup java -jar spring-boot-1.0-SNAPSHOT.jar > log.file 2>& ...

  5. 根据抽象工厂实现的DBHelpers类

    public abstract class DBHelper { public static SqlConnection conn = new SqlConnection("server=l ...

  6. C语言学习(一)

    C语言易学难精,如果在平时的编程中,加入一些小技巧,可以提供程序运行的效率,何乐而不为呢? 本小白初学C语言准备记录自己的学C之路,经常贴一些自己觉得优化的小程序代码,希望大神们不吝 赐教. 宏定义下 ...

  7. xftp上传文件失败,执行程序发现磁盘满了:No space left on device

    参考链接 No space left on device 解决Linux系统磁盘空间满的办法http://www.cnblogs.com/aspirant/p/3604801.html如何解决linu ...

  8. Docker学习笔记 - Docker客户端和服务端

    学习内容: Docker客户端和服务端的通讯方式:client和自定义程序 Docker客户端和服务端的连接方式:socket 演示Docker客户端和服务端之间用remote-api通讯:nc   ...

  9. HRBUST1522【单调队列+DP】

    题目:输入一个长度为n的整数序列(A1,A2,--,An),从中找出一段连续的长度不超过m的子序列,使得这个子序列的和最大. #include<stdio.h> #include<s ...

  10. python模块之PIL模块

    PIL简介 什么是PIL PIL:是Python Image Library的缩写,图像处理的模块.主要的类包括Image,ImageFont,ImageDraw,ImageFilter PIL的导入 ...