# Climbing the Hill

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 919    Accepted Submission(s): 411

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?

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.

Output
If Alice can win, output "Alice". If not, output "Bob".

Sample Input
3 3
1 2 4
2 1
100 200

Sample Output
Bob
Alice

Hint

The 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.

Author
TJU

Source

``` #include<cstring>
#include<cstdio>
#include<cstdlib>
];
int n,k;
int main()
{
while(scanf("%d%d",&n,&k)!=EOF)
{
;i<n;i++)
scanf("%d",&aa[i]);
;
)
{
puts("Alice");
continue;
}
==)  //偶数堆
{
;i<n;i+=)
ans^=(aa[i]-aa[i-]-);
}
else
{
) ans=aa[]-;
];
;i<n;i+=)
ans^=(aa[i]-aa[i-]-);
}
if(ans)  puts("Alice");
else puts("Bob");
}
;
}```

## hdu 4315 Climbing the Hill（阶梯博弈转nim博弈）的更多相关文章

1. HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)

Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Su ...

2. HDU 4315 Climbing the Hill [阶梯Nim]

传送门 题意: 和上题基本一样:山顶可以有多人,谁先把king放到山顶谁就胜 并不太明白 #include <iostream> #include <cstdio> #incl ...

3. hdu 4315 Climbing the Hill 博弈论

题意:有n个人爬山,山顶坐标为0,其他人按升序给出,不同的坐标只能容纳一个人(山顶不限),Alice和Bob轮流选择一个人让他移动任意步,但不能越过前面的人,且不能和前面一个人在相同的位置.现在有一个 ...

4. HDU 2509 Nim博弈变形

1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

5. HDU 1907 Nim博弈变形

1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

6. hdu 1907 John&amp;&amp; hdu 2509 Be the Winner（基础nim博弈）

Problem Description Little John is playing very funny game with his younger brother. There is one bi ...

7. HDU - 1850 Nim博弈

思路:可以对任意一堆牌进行操作,根据Nim博弈定理--所有堆的数量异或值为0就是P态,否则为N态,那么直接对某堆牌操作能让所有牌异或值为0即可,首先求得所有牌堆的异或值,然后枚举每一堆,用已经得到的异 ...

8. zoj3591 Nim(Nim博弈)

ZOJ 3591 Nim(Nim博弈) 题目意思是说有n堆石子,Alice只能从中选出连续的几堆来玩Nim博弈,现在问Alice想要获胜有多少种方法(即有多少种选择方式). 方法是这样的,由于Nim博 ...

9. [博弈]ZOJ3591 Nim

题意: 给了一串数,个数不超过\$10^5\$,这串数是通过题目给的一段代码来生成的 int g = S; ; i<N; i++) { a[i] = g; ) { a[i] = g = W; } = ...

## 随机推荐

1. UVA, 10336 Rank the Languages

难点在于:递归函数和输出: #include <iostream> #include <vector> #include <algorithm> #include ...

2. iOS之关于 srand() 和rand()

srand(seed)用来将随机序列的起始点设为seed srand((int)time(0))表示以当前时间对应的int值为随机序列起点,这样每次运行程序,由于起点不同才可以得到不同的随机数 tim ...

3. Linux find 用法示例

Linux中find常见用法示例 ·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \; find命令的参数 ...

4. 【转载】移动web开发经验总结

本文出自: http://blog.163.com/hsb001_mobile/blog/static/15524028020111177221254/ 1.-webkit-tap-highlight ...

5. Mysql数据库的一些命令_LInux

6. Ubuntu jsp平台使用JDBC来连接MySQL数据库

Ubuntu 7.04 搭建Ubuntu jsp平台开发环境MySQL+tomcat+apache+j2sdk1.6在所有安装开始前先在Terminal中输入 rpm -q -a查看是否安装过rpm ...

7. Python开发简单爬虫 - 慕课网

课程链接:Python开发简单爬虫 环境搭建: Eclipse+PyDev配置搭建Python开发环境 Python入门基础教程 用Eclipse编写Python程序   课程目录 第1章 课程介绍 ...

8. 报错：org.apache.jasper.JasperException: /index.jsp (line: 1, column: 17) equal symbol expected

现象:写了如下一个jsp文件,导入需要用到的两个包: 运行结果报错:org.apache.jasper.JasperException: /index.jsp (line: 1, column: 17 ...

9. ubuntu ip

一.使用命令设置Ubuntu IP地址 1.修改配置文件blacklist.conf禁用IPV6 sudo vi /etc/modprobe.d/blacklist.conf 在文档最后添加 blac ...

10. openquery链表删除时报错 “数据提供程序或其他服务返回 E_FAIL 状态”

DELETE OPENQUERY (VERYEAST_COMPANY_MYSQL_CONN, 'SELECT * FROM company ') WHERE c_userid in(select c_ ...