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. 扩充巴科斯-瑙尔范式 ABNF简介

    扩充巴科斯-瑙尔范式(ABNF)是一种基于巴科斯-瑙尔范式(BNF)的元语言,但它有自己的语法和派生规则.ABNF的原动原则是描述一种作为双向通信协议的语言. ABNF是由第68号互联网标准(&quo ...

  2. CSS流体(自适应)布局下宽度分离原则——张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1463 一.简短的前言 ...

  3. nodejs学习 之 安装

    1. 官网找最新适合自己电脑的版本  下载  https://nodejs.org/en/download/ 2.我的是win7 x64选择了msi的安装包,安装过程修改安装的目标目录,最好不要放在c ...

  4. OpenGL学习--05--纹理立方体--BMP文件格式详解(转载)

    http://blog.csdn.net/o_sun_o/article/details/8351037 BMP文件格式详解 BMP文件格式详解(BMP file format) BMP文件格式,又称 ...

  5. 云卡门禁苹果SDK_BLEDOOR_SDK_IOS_2016_12_15

    // // BLElib.h // BLElib // // Created by szbosk on 16/8/16. // Copyright © 2016年 szbosk. All rights ...

  6. 直到黎明 Until Dawn 后感

    直到黎明 会免游戏.白金神作.近些年的恐怖电影都有游戏化的趋势,韩国的某岩vlog,美国的真心话大冒险,都把观众作为meta代入游戏,几乎模糊了游戏与游戏的边界,直到黎明这部电影,与当年的暴雨和超凡双 ...

  7. CDH5.11安装spark2.x详细步骤

    简介: 在我的CDH5.11集群中,默认安装的spark是1.6版本,这里需要将其升级为spark2.x版本.经查阅官方文档,发现spark1.6和2.x是可以并行安装的,也就是说可以不用删除默认的1 ...

  8. 将远程UI分支克隆到本地UI分支

    git checkout -b UI git remote add origin <url> git fetch origin git branch --track UI origin/U ...

  9. Object 类型

    Object 类型 ECMAScript中大多数的引用类型都值都是Object类型的实例,Object也是使用最多的一个类型,主要用来在程序中存储和传输数据 创建Object实例的两种方式 使用new ...

  10. Asp.net mvc Kendo UI Grid的使用(三)

    上一篇的操作已经能够显示基本数据了,这次介绍一下如何进行数据操作以及显现自定义命令. 第一步当然还是准备数据: [HttpPost] public ActionResult PersonalList_ ...