Football Game

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 451   Accepted: 178

Description

Alice and Bob both love football very much, and both of them are vanguards. They are both good at football control. One day after a football match, they play an interesting game, in which they shoot footballs forward the goal directly. There are N footballs in front of the goal, and they play this game in turn. For example, if it is Alice's turn, Alice can choice some footballs (the number of footballs mush equal or less than M) and shoot them forward. Because the footballs' quality is not very good, footballs are not a complete sphere and can only roll integer times of its girth. And because of restriction of the friction and strength of them, they cannot shoot a football farther then L centimeters. Of course, they know the radius of a football is R centimeters. Alice and Bob love this game very much. If both of them have unlimited IQ and precision shooting skill, can you guess who can win the football game? By the way, though Alice is as strong as Bob, Alice is a girl, so she will shoot first.

Input

The input consists of several cases, each of which contains two lines.

For each test case, the first line contains 4 integers N, M, L and R (1 <= M <= N <= 30, 0 < L < 100000000, 0 < R < 10000), separated by a single space. N is the number of the footballs, M is the maximum number of footballs one player can shot in one turn, L is the maximum distance that a player can shoot, and R is the radius of footballs.

The next line contains N numbers, S(1), S(2), ..., S(N) (0 < S(i) < 100000000), which describe the distance between footballs and the goal.

Output

For each case output contains one line describing the name of the winner.

Sample Input

2 1 30 1
8 14
2 1 30 1
8 12
2 1 30 1
8 10
2 1 30 1
40 200

Sample Output

Alice
Bob
Bob
Bob

Source

 
 
题意概括:
有 N 个足球每个距离球门 D 远,两人轮流选择小于等于 M 个球射门, 射球最远距离为 L,球的半径为 R (球每次只能移动 周长的整数倍),最后射球者胜,先手赢还是后手赢;
解题思路:
首先要求问题进行转换 N 个球相当于 N 堆物品, 由于每个球只能滚动 周长的整数倍,所以可以把 球到球门的距离 离散化(即选多少个物品),而由于射门有最大距离,所以选取范围 小于 K,(单独看单堆即 Bash 博弈)
接下来考虑 NIM 游戏的变形,普通的 NIM 游戏 每次选取一个堆取若干物品,NIMK 游戏 每次选取 ≤ K 个堆取若干物品。
结论 同样是异或所有堆数,不过不是 模二异或 而是 模(K+1)异或。奇异局势为必败态。 
 
AC code:
 //#include <bits/stdc++.h>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define inc(i, j, k) for(int i = j; i <= k; i++)
#define rep(i, j, k) for(int i = j; i < k; i++)
#define F(x) ((x)/3+((x)%3==1?0:tb))
#define G(x) ((x)<tb?(x)*3+1:((x)-tb)*3+2)
#define INF 0x3f3f3f3f
#define LL long long
#define MEM(i, j) memset(i, j, sizeof(i));
#define gcd(i, j) __gcd(i, j)
using namespace std;
const int MAXN = 1e5+;
const double PI = acos(-1.0);
int SG[MAXN];
int XOR[MAXN];
int xxx;
int num;
int maxn; bool solve(int N, int M)
{
MEM(XOR, );
maxn = -;
inc(i, , N){
xxx = SG[i];
num = ;
while(xxx){
XOR[num]+=xxx&;
num++;
xxx>>=;
}
maxn = max(maxn, num);
}
rep(i, , maxn){
if(XOR[i]%(M+)) return true;
}
return false;
}
int N, M, L, R;
int s; int main()
{
while(~scanf("%d %d %d %d", &N, &M, &L, &R)){
s = L/(*PI*R); //最远的距离
inc(i, , N){
scanf("%d", &SG[i]);
SG[i] = SG[i]/(*PI*R) + ; //距离球门的距离
SG[i]%=s+; // Bash博弈
}
if(solve(N, M)) puts("Alice"); //NIMK 博弈
else puts("Bob");
}
return ;
}
 
 

POJ Football Game 【NIMK博弈 && Bash 博弈】的更多相关文章

  1. poj 1704 Georgia and Bob(阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9363   Accepted: 3055 D ...

  2. HDU 2188 基础bash博弈

    基础的bash博弈,两人捐钱,每次不超过m,谁先捐到n谁胜. 对于一个初始值n,如果其不为(m+1)的倍数,那么先手把余数拿掉,后继游戏中不管如何,后手操作后必定会有数余下,那么先手必胜,反之后手必胜 ...

  3. HDU 1525 类Bash博弈

    给两数a,b,大的数b = b - a*k,a*k为不大于b的数,重复过程,直到一个数为0时,此时当前操作人胜. 可以发现如果每次b=b%a,那么GCD的步数决定了先手后手谁胜,而每次GCD的一步过程 ...

  4. HDU 2897 邂逅明下 ( bash 博弈变形

    HDU 2897 邂逅明下 ( bash 博弈变形 题目大意 有三个数字n,p,q,表示一堆硬币一共有n枚,从这个硬币堆里取硬币,一次最少取p枚,最多q枚,如果剩下少于p枚就要一次取完.两人轮流取,直 ...

  5. bash 博弈

    转载并修改自: http://www.cnblogs.com/wulangzhou/archive/2013/03/14/2959660.html 简单的取拿游戏一堆石子(或者其它的什么东西),下面是 ...

  6. POJ1704 Georgia and Bob 博弈论 尼姆博弈 阶梯博弈

    http://poj.org/problem?id=1704 我并不知道阶梯博弈是什么玩意儿,但是这道题的所有题解博客都写了这个标签,所以我也写了,百度了一下,大概是一种和这道题类似的能转换为尼姆博弈 ...

  7. luogu P2252 威佐夫博弈 模板 博弈

    LINK:威佐夫博弈 四大博弈 我都没有好好整理 不过大致可以了解一下. 在这个博弈中 存在一些局面 先手遇到必胜. 不过由于后手必胜的局面更具规律性这里研究先手遇到的局面后手必胜的情况. 这些局面分 ...

  8. poj 2484 A Funny Game(博弈)

    A Funny Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4639   Accepted: 2855 Desc ...

  9. 51Nod 1067 Bash博弈V2

    这道题告诉我,一定要去尝试,去推算,不要动不动就找度娘要答案.(惭愧惭愧) 既然是博弈问题,按理我们应该找出规律,怎么找呢,推,把前几项写出来找规律,动手很重要. 上题: 1067 Bash游戏 V2 ...

随机推荐

  1. Tomcat配置JVM参数步骤

    这里向大家描述一下如何使用Tomcat配置JVM参数,Tomcat本身不能直接在计算机上运行,需要依赖于硬件基础之上的操作系统和一个java虚拟机.您可以选择自己的需要选择不同的操作系统和对应的JDK ...

  2. gRPC 的route_guide例子

      本文的例子代码在: https://github.com/grpc/grpc-go/tree/master/examples/route_guide 功能就类似目前LBS一样,在每个位置上报一些文 ...

  3. ef oracle参数化问题

    并非所有变量都已绑定 假如一个sql是这样的 string sql =@" select id from a where date between :StartDate and :EndDa ...

  4. HTML存储详解

    和大家一起先来了解一下H5之前的存储方式: cookies的诞生: http请求头上带着数据 大小只能为4K 主Domain的污染 下面是百度的一些Cookies HTTP中带√的表示,只能被服务器端 ...

  5. Ubuntu中利用rename批量重命名

    1.简介: 通常在机器视觉的学习过程中,需要批量处理一些图片,通常会涉及到批量重命名的问题,可以利用rename命令快速实现图片的批量重命名 2.rename命令格式: rename [-v] [-n ...

  6. opencv之图像拼接

    参考博客http://blog.csdn.net/u011630458/article/details/44175965 博主:羽凌寒 之后再进行系统学习

  7. LeetCode 545----Boundary of Binary Tree

    Given a binary tree, return the values of its boundary in anti-clockwise direction starting from roo ...

  8. TestNG 判断文件下载成功

    用WatchService写一个方法放在onTestStart()方法里监听文件夹的变化. 但是判断下载成功还需要写一个方法, 用来判断什么时候文件从.xlsx.rcdownload改成.xlsx才行 ...

  9. clean-css

    What is clean-css? Clean-css is a fast and efficient Node.js library for minifying CSS files. Accord ...

  10. VC++下使用ADO操作数据库

    VC++下使用ADO操作数据库主要要用到 _ConnectionPtr,_CommandPtr,_RecordsetPtr三个ADO对象指针,我查找了相关资料,发现网上源码很多,但是都相对凌乱,于是自 ...