poj 2315 Football Game nimk 博弈
来源:互联网 发布:mac microsoft公式3.0 编辑:程序博客网 时间:2024/06/05 11:46
Football Game
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 332 Accepted: 118
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.
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 18 142 1 30 18 122 1 30 18 102 1 30 140 200
Sample Output
AliceBobBobBob
题意:给你 n 个球 某个人最多一次踢球的个数 能踢的最远的距离 l 和半径r
接下来一行是n个球 距离球门的距离。
两个人轮流踢 知道有一个人把最后一个球踢进去为赢 。
注意 踢的最远距离为l 但是不一定踢l 每一踢球必须为周长的整数倍并且小等于l
思路: 其实转换一下就可以发现 是一种nim 博弈 问题 对于每一个球距离球门
的距离我们可以转换成至少要踢多少下才可以踢到 球门里边 而能踢的最长距离为l
也可以转换成 最多 踢几次 那么就转化成了 一种 nim 游戏
给你n堆石子 每堆有x个 每一次可以从m 堆中取出 k 个 (每一堆都可以取出k个)
最后取完的为胜者。 问谁胜。
nimk 博弈 : nimk 博弈的博客
代码:
#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#define PI acos(-1)#define N 35using namespace std;int s[N];int xorr[205];int n,m,l,r;double dis;int k;int solve(){memset(xorr,0,sizeof(xorr));int maxcnt=-1;for(int i=1;i<=n;i++){int num=s[i];int cnt=0;for(int j=0;num;j++,num>>=1){xorr[j]+=num&1;cnt++;maxcnt=max(cnt,maxcnt);}}for(int i=0;i<maxcnt;i++){if(xorr[i]%(m+1)) return 1;}return 0;}int main(){while(cin>>n>>m>>l>>r){for(int i=1;i<=n;i++) cin>>s[i];dis=2*PI*r;k=floor(l*1.0/dis)+1;for(int i=1;i<=n;i++){s[i]=floor(s[i]*1.0/dis);s[i]++;s[i]%=k;}int f=solve();if(f) printf("Alice\n");else printf("Bob\n");}return 0;}
阅读全文
0 0
- NIMK博弈游戏,POJ-2315 Football Game
- poj 2315 Football Game nimk 博弈
- poj 2315 Football Game (博弈 nim k game)
- POJ 2315 Football Game 已翻译
- poj 2234 Matches Game (博弈)
- [博弈]POJ 2234 Matches Game
- POJ 2234 Matches Game(博弈)
- BZOJ4550 小奇的博弈 【Nimk游戏 + dp + 组合数】
- poj 1740 A New Stone Game( 博弈)
- POj-2348-Euclid's Game-博弈
- POJ 2599 A funny game [DFS博弈]
- POJ 1082 Calendar Game (博弈)
- poj 1740 A New Stone Game(博弈)
- poj 2505 A multiplication game(博弈)
- poj 1082 Calendar Game——博弈
- POJ 2599 A funny game (搜索,博弈)
- 博弈 POJ A New Stone Game
- [博弈] poj 1067 #裸的Wythoff Game
- 1058. 选择题(20)
- 修改idea远程仓库地址
- [Python高效编程]
- VI指令
- JS中的事件处理和文档处理应该记住哪些内容。。。
- poj 2315 Football Game nimk 博弈
- 土地经济学笔记第一部分
- 投影波峰查找
- ubuntu16.04+caffe+GTX1060+DIGITS安装方法
- 求出满足下列条件的四位数:该数是个完全平方数,且第一、三位数字之和为10,第二、四位数字之积为12
- 机器视觉起步之数字图像处理(冈萨雷斯)
- wannafly挑战赛4
- MySQL--字符串长度
- web开发入门课---web技术发展历程