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. Myeclipse默认编码设置

    Myeclipse默认编码设置 由于编码问题的出现,我们就必须明确自己在Myeclipse所写的各种文件是按照什么格式来进行编码的.所以只有知己知彼,才能bug少出. 对于刚接触MyEclipse的不 ...

  2. Linux:网络工具 nc

    虽然叫nc不过用起来非常方便. 选项 - Use IPv4 only - Use IPv6 only -U, --unixsock Use Unix domain sockets only -C, - ...

  3. 小tip: base64:URL背景图片与web页面性能优化——张鑫旭

    一.base64百科 Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,可用于在HTTP环境下传递较长的标识信息. 某人: 唉,我彻底废柴了,为何上面明明是中文,洒家却看不懂嘞,为什 ...

  4. display:table-cell自适应布局下连续单词字符换行——张鑫旭

    之前有几次提到了使用display:table-cell实现强大的任意尺寸元素的自适应布局(都藏在长长文章之中).这里开篇再次提一下,希望能将该技术普及下去. 典型的双栏布局类名使用如下: fix l ...

  5. spring-boot-starter-actuator不起作用

    spring-boot-starter-actuator的作用,actuator是监控系统健康情况的工具.使用这个功能首先要先添加依赖,如下.<!-- 监控和管理生产环境--><de ...

  6. OpenGL学习--07--模型加载(obj)

    1.tutorial07.cpp // Include standard headers #include <stdio.h> #include <stdlib.h> #inc ...

  7. 1000! mod 10^250

    1000! mod 10^250  =============== the answer is 2 ================ Hi I'm trying to solve the above ...

  8. SwipeRefreshLayout的高度测量

    感谢此作者的分享 http://www.cnblogs.com/linjzong/p/5221604.html 若SwipeRefreshLayout的子布局为一个线性布局LinearLayout, ...

  9. String path = request.getContextPath

    <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...

  10. Android使用ToolBar+DrawerLayout+NavigationView实现侧滑抽屉效果

    学会使用DrawerLayout 学会使用NavigationView 学会使用ToolBar+DrawerLayout+NavigationView实现侧滑抽屉效果 学会实现Toolbar在顶部以及 ...