Game HDU - 3389 (博弈论)
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 (博弈论)的更多相关文章
- HDU 3389 阶梯博弈变形
n堆石子,每次选取两堆a!=b,(a+b)%2=1 && a!=b && 3|a+b,不能操作者输 选石子堆为奇数的等价于选取步数为奇数的,观察发现 1 3 4 是无法 ...
- 悼念512汶川大地震遇难同胞——选拔志愿者 HDU 2188 博弈论 巴什博奕
悼念512汶川大地震遇难同胞--选拔志愿者 HDU 2188 博弈论 巴什博奕 题意 对于四川同胞遭受的灾难,全国人民纷纷伸出援助之手,几乎每个省市都派出了大量的救援人员,这其中包括抢险救灾的武警部队 ...
- 取(2堆)石子游戏 HDU 2177 博弈论
取(2堆)石子游戏 HDU 2177 博弈论 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中 ...
- 取石子游戏 HDU 1527 博弈论 威佐夫博弈
取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两 ...
- hdu 3389 Game 博弈论
思路: 其本质为阶梯博弈; 阶梯博弈:博弈在一列阶梯上进行,每个阶梯上放着自然数个点,两个人进行阶梯博弈... 每一步则是将一个集体上的若干个点( >=1 )移到前面去,最后没有点可以移 ...
- 【hdu 3389】Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...
- hdu 3389 Game (阶梯博弈)
#include<stdio.h> int main() { int t,n,ans; int i,j,x; scanf("%d",&t); ;j<=t; ...
- HDU 3389 (Nim博弈变形) Game
参考了众巨巨的博客,现在重新整理一下自己的思路. 首先在纸上画了一下转移图: 1 3 4号盒子是不能够再转移卡片到其他盒子中去了的,其他盒子中的卡片经过若干步的转移最终也一定会转移到1 3 4号盒子中 ...
- hdu 3389 阶梯博弈
题意:1-N带编号的盒子,当编号满足A>B && A非空 && (A + B) % 3 == 0 && (A + B) % 2 == 1则可以从A ...
随机推荐
- java_manual的一点体会
最近看了一下Alibaba的java_manual1.4,看了感觉有很多好的标准,这里摘录一些,也帮助自己的代码更加规范化 先放一些MySQL的规范: 这里附上MySQL官网给的参考手册上的 关键字和 ...
- String、StringBuffer、StringBuilder三种类型的一点比较
简要记一点 以运行速度来说: StringBuilder>StringBuffer>String 以线程安全来说: StringBuilder线程不安全,而StringBuffer线程安全 ...
- 导出数据到EXL表格中
项目使用的是SSI框架,通过struts访问到action xml文件: <action name="fabAttributedaochu" class="com. ...
- Razor Pages with ASP.NET Core 2
With ASP.NET Core 2 we get another way of building web applications. It’s one of those new things th ...
- Span<T>
Introduction Span<T> is a new type we are adding to the platform to represent contiguous regio ...
- 【C/C++】查找(一):静态查找表
{静态查找表 + 动态查找表} 所谓动态,就是,找的时候没有则添加,或者能删除 关键字:primary key:用来表示查找表中的一条记录 {主关键字 + 次关键字} 主关键字是唯一的,用来唯一的标识 ...
- 删除本地git的远程分支和远程删除git服务器的分支【转】
转- 删除本地git的远程分支和远程删除git服务器的分支 在项目中使用git管理代码后,有些时候会创建很多不同名称的分支,以此区分各个分支代码功能. 而随着代码的合并,以前的分支就可能不再需要保存了 ...
- 使用aapt查看当前apk的属性
android:versioncode——整数值,代表应用程序代码的相对版本,也就是版本更新过多少次. android:versionname——字符串值,代表应用程序的版本信息,需要显示给用户. e ...
- python 项目启动路径自动添加
import os import sys base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #找到当前项目 ...
- BZOJ2554 color 【概率DP】【期望DP】
题目分析: 好题. 一开始看错题了,以为是随机选两个球,编号在前的染编号在后的. 但这样仍然能获得一些启发,不难想到可以确定一个颜色,剩下的颜色是什么就无关了. 那么答案就是每种颜色的概率乘以期望.概 ...