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. 一个简单的DLL生成和测试

    DLL文件内容: SKLDll.h #ifndef _SKLDLL_H_#define _SKLDLL_H_ #ifndef DLL_API #define DLL_API extern " ...

  2. 设计模式学习——抽象工厂模式(Abstract Factory Pattern)

    现有一批装备(产品),分为不同的部位(上装.下装)与不同的等级(lv1.lv2).又有不同lv的工厂,只生产对应lv的全套装备. 代码实现上...本次写得比较偷懒,函数实现都写在头文件了.... 有些 ...

  3. css3中Animation

    CSS3我在5年之前就有用了,包括公司项目都一直在很前沿的技术. 最近在写慕课网的七夕主题,用了大量的CSS3动画,但是真的沉淀下来仔细的去深入CSS3动画的各个属性发现还是很深的,这里就写下关于帧动 ...

  4. Firbe Channel光纤信道

    简介 中文名:网状信道 外文名:Fibre Channel 简    称:FC 光纤信道是一种高速网络技术标准(T11),主要应用于SAN(存储局域网).其拓扑结构分为三种,点到点.仲裁循环.交换结构 ...

  5. CSS实现跨浏览器兼容性的盒阴影效果

    .shadow { -moz-box-shadow: 3px 3px 4px #000; -webkit-box-shadow: 3px 3px 4px #000; box-shadow: 3px 3 ...

  6. setTimeout OR setInterval?

    setTimeout 和setInterval从字面上应该是可以知道其大意的.timeout:延时:interval:间隔: 两者的区别就像是它们自己的英文解释一样:setTimeout是延时执行,并 ...

  7. 5分钟搞定jQuery+zepto.js+面向对象插件

    今天分享一下快速使用jQuery+zepto.js的技巧,需要的记得收藏 1.jQuery的引入:本地下载jQuery(后面简称jq)的源文件,开发版本使用非min版,线上使用min版,zepto.j ...

  8. 图片按钮(imageButton)

    图片按钮(imageButton) 常用属性: android:src="@drawable/download" (这里的download是一张图片的名称,通过引用该图片的名称直接 ...

  9. ES6中的import与export对class操作相关用法举例

    两种用法: 一.指定输出类名 // export 输出 export class App extends React.Componet { // ..code } // import 引入 impor ...

  10. Html 表单标签 Form

    Html表单 #转载请留言联系 表单用于搜集不同类型的用户输入,表单由不同类型的标签组成,相关标签及属性用法如下: 1.<form>标签 定义整体的表单区域 action属性 定义表单数据 ...