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.

InputThe 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.OutputFor 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 题意:
编号可以满足B<A && (A+B)%2=1 && (A+B)%3=0就可以把石子从A移动到B。 思路:
阶梯博弈 问题导入我就不BB了,普通阶梯博弈的结论就是奇数阶的异或和。
1.1 如果先手必败,挪动偶数阶的石子,对方肯定将挪动的石子再次挪到偶数阶上,保持你的必败状态。
1.2 如果先手必败,挪动奇数阶的石子,相当于取走nim博弈中的石子,你的必败态并未改变。
2.1 如果先手必胜,挪动偶数阶的石子。。。。。你没有必要这么做。。
2.2 如果先手必胜,挪动奇数阶的石子,就把问题1.1,1.2丢给了对方。 这个题画个图,变形一下就行了。
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#define fuck(x) cout<<#x<<" = "<<x<<endl;
#define ls (t<<1)
#define rs ((t<<1)+1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = ;
const int inf = 2.1e9;
const ll Inf = ;
const int mod = ;
const double eps = 1e-;
const double pi = acos(-);
int n;
int num[maxn];
int main()
{
// ios::sync_with_stdio(false);
// freopen("in.txt","r",stdin); int T;
int cases=;
scanf("%d",&T);
while(T--){
cases++;
scanf("%d",&n);
int ans=,x;
for(int i=;i<=n;i++){
scanf("%d",&x);
if(i%==||i%==||i%==){
ans^=x;
}
}
printf("Case %d: ",cases);
if(ans){printf("Alice\n");}
else printf("Bob\n");
} return ;
}

Game HDU - 3389 (博弈论)的更多相关文章

  1. HDU 3389 阶梯博弈变形

    n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输 选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法 ...

  2. 悼念512汶川大地震遇难同胞——选拔志愿者 HDU 2188 博弈论 巴什博奕

    悼念512汶川大地震遇难同胞--选拔志愿者 HDU 2188 博弈论 巴什博奕 题意 对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队 ...

  3. 取(2堆)石子游戏 HDU 2177 博弈论

    取(2堆)石子游戏 HDU 2177 博弈论 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中 ...

  4. 取石子游戏 HDU 1527 博弈论 威佐夫博弈

    取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两 ...

  5. hdu 3389 Game 博弈论

    思路: 其本质为阶梯博弈; 阶梯博弈:博弈在一列阶梯上进行,每个阶梯上放着自然数个点,两个人进行阶梯博弈...     每一步则是将一个集体上的若干个点( >=1 )移到前面去,最后没有点可以移 ...

  6. 【hdu 3389】Game

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  7. hdu 3389 Game (阶梯博弈)

    #include<stdio.h> int main() { int t,n,ans; int i,j,x; scanf("%d",&t); ;j<=t; ...

  8. HDU 3389 (Nim博弈变形) Game

    参考了众巨巨的博客,现在重新整理一下自己的思路. 首先在纸上画了一下转移图: 1 3 4号盒子是不能够再转移卡片到其他盒子中去了的,其他盒子中的卡片经过若干步的转移最终也一定会转移到1 3 4号盒子中 ...

  9. hdu 3389 阶梯博弈

    题意:1-N带编号的盒子,当编号满足A>B && A非空 && (A + B) % 3 == 0 && (A + B) % 2 == 1则可以从A ...

随机推荐

  1. bootstrap簡介

    bootstarp是最受歡迎的前端開發框架,可以開發數適用pc.平板電腦和手機的web應用,是基於html.css和javascript.只要學會bootstarp,就代表具有web的開發的中級水準.

  2. MySQL 5.7 关闭严格模式

    If your app was written for older versions of MySQL and is not compatible with strict SQL mode in My ...

  3. [oracle] to_date() 与 to_char() 日期和字符串转换

    to_date("要转换的字符串","转换的格式")   两个参数的格式必须匹配,否则会报错. 即按照第二个参数的格式解释第一个参数. to_char(日期,& ...

  4. Visual Studio 2017 and Swagger: Building and Documenting Web APIs

    Swagger是一种与技术无关的标准,允许发现REST API,为任何软件提供了一种识别REST API功能的方法. 这比看起来更重要:这是一个改变游戏技术的方式,就像Web服务描述语言一样WSDL( ...

  5. Nginx用户权限验证管理

    首先需要编译进--with-http_request_model 配置指令:auth_request url | off; #url是指上游服务器地址 context: http/location 备 ...

  6. Ubuntu18.04安装RabbitMQ

    Ubuntu18.04安装RabbitMQ 2018年06月10日 19:32:38 dmfrm 阅读数:2492    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog ...

  7. 了解AutoCAD对象层次结构 —— 1 ——应用程序

    想象这样一个场景:当您开始一天的工作,坐到电脑前面,用鼠标双击桌面上的AutoCAD Civil 3D图标,这时一个AutoCAD Civil 3D应用程序将运行起来.打开Windows任务管理器,我 ...

  8. python数学库math模块

    函数 数学表示 含义 .pi 圆周率π π的近似值,15位小数 .e 自然常数 e e的近似值,15位小数 ceil(x) [x] 对浮点数向上取整 floor(x) [x] 对浮点数向下取整 pow ...

  9. AHOI(十二省联考)2019 退役记

    我也想退役失败.jpg Day 0 我才知道联考原来是4.5h? 下午居然还有讲题,感觉变得正规多了. 试机敲了LCT,NTT,SA,加起来花了大概40min,基本1A,感觉海星.键盘似乎有点过于灵敏 ...

  10. Google浏览器——AxureRP_for_chorme_0_6_2添加

    准备 链接:https://share.weiyun.com/5PVwSMA Google浏览器版本 步骤 压缩解压 首先把需要安装的第三方插件,后缀.crx 改成 .rar,然后解压,得到一个文件夹 ...