hdu4315 Climbing the Hill
来源:互联网 发布:天下3男号捏脸数据 编辑:程序博客网 时间:2024/04/29 00:17
Climbing the Hill
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 725 Accepted Submission(s): 335
Problem Description
Alice and Bob are playing a game called "Climbing the Hill". The game board consists of cells arranged vertically, as the figure below, while the top cell indicates the top of hill. There are several persons at different cells, and there is one special people, that is, the king. Two persons can't occupy the same cell, except the hilltop.
At one move, the player can choose any person, who is not at the hilltop, to climb up any number of cells. But the person can't jump over another one which is
above him. Alice and Bob move the persons alternatively, and the player who move the king to the hilltop will win.
Alice always move first. Assume they play optimally. Who will win the game?
At one move, the player can choose any person, who is not at the hilltop, to climb up any number of cells. But the person can't jump over another one which is
above him. Alice and Bob move the persons alternatively, and the player who move the king to the hilltop will win.
Alice always move first. Assume they play optimally. Who will win the game?
Input
There are several test cases. The first line of each test case contains two integers N and k (1 <= N <= 1000, 1 <= k <= N), indicating that there are N persons on the
hill, and the king is the k-th nearest to the top. N different positive integers followed in the second line, indicating the positions of all persons. (The hilltop is No.0 cell, the cell below is No.1, and so on.) These N integers are ordered increasingly, more than 0 and less than 100000.
hill, and the king is the k-th nearest to the top. N different positive integers followed in the second line, indicating the positions of all persons. (The hilltop is No.0 cell, the cell below is No.1, and so on.) These N integers are ordered increasingly, more than 0 and less than 100000.
Output
If Alice can win, output "Alice". If not, output "Bob".
Sample Input
3 31 2 42 1100 200
Sample Output
BobAliceHintThe figure illustrates the first test case. The gray cell indicates the hilltop. The circles indicate the persons, while the red one indicates the king. The first player Alice can move the person on cell 1 or cell 4 one step up, but it is not allowed to move the person on cell 2.这题,虽然和上一题的博弈是一样的,也可以转化成上一题中的,移动石子,但是,有一个问题老是想不明白,为什么这一题,是奇数且为第二个的时候,会是特殊情况,以后再想吧!#include <iostream>#include <stdio.h>#include <string.h>using namespace std;#define M 1005int pri[M];int main(){ int n,k,ans,i; while(scanf("%d%d",&n,&k)!=EOF){ for(i=1;i<=n;i++) scanf("%d",&pri[i]); if(k==1){ printf("Alice\n"); continue; } ans=0;i--; while(i>1){ ans^=(pri[i]-pri[i-1]-1);i=i-2; } if(n&1){ if(k==2) ans^=(pri[1]-1); else ans^=pri[1]; } if(ans)printf("Alice\n"); else printf("Bob\n"); } return 0;}
- hdu4315 Climbing the Hill
- hdu4315 Climbing the Hill 转化NIM模型
- hdu4315 Climbing the Hill(阶梯博弈)
- [HDU4315]Climbing the Hill(阶梯博弈)
- Climbing the Big Nan Hill
- hdu 4315 Climbing the Hill
- 【hdoj 4315】Climbing the Hill
- 【hdu 4315】Climbing the Hill
- hdu - 4315 - Climbing the Hill - 博弈
- hdu 4315 Climbing the Hill 博弈
- hdu 4315 Climbing the Hill (阶梯博弈)
- HDU 4315 Climbing the Hill Staircase Nim变种
- HDU 4315 Climbing the Hill(尼姆博弈变形)
- HDOJ 题目4315Climbing the Hill(阶梯博弈)
- Climbing the Hill - HDU 4315 阶梯博弈变形
- hdu 4315 Climbing the Hill (阶梯博弈)
- HDU-4315 Climbing the Hill(阶梯博弈变形)
- HDU-4315 Climbing the Hill(阶梯博弈)
- win7与ubuntu12.10双系统下硬盘安装centos5.3
- Thinkpad在Ubuntu下禁用触摸板但不禁用小红帽
- java Label
- 《程序员面试宝典》第3版大量错误纠正表
- 创新工场笔试题2014 校园招聘 ---武汉站
- hdu4315 Climbing the Hill
- android camera无预览拍照 后台拍照
- 2014优酷笔试题
- hdu 1527(威佐夫博弈)
- MFC的二级缓存绘图
- jsp记录
- VC CEvent类的介绍(手工重置、自动重置)
- 百度地图定位到的地理位置通过串口传递给单片机方案
- java开发基础知识