hdu 4315 Climbing the Hill(阶梯博弈转nim博弈)
2014-10-25 10:30
369 查看
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[align=left]Problem Description[/align]
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.
#include<cstring> #include<cstdio> #include<cstdlib> int aa[1005]; int n,k; int main() { while(scanf("%d%d",&n,&k)!=EOF) { for(int i=0;i<n;i++) scanf("%d",&aa[i]); int ans=0; if(k==1) { puts("Alice"); continue; } if(n%2==0) //偶数堆 { for(int i=1;i<n;i+=2) ans^=(aa[i]-aa[i-1]-1); } else { if(k==2) ans=aa[0]-1; else ans=aa[0]; for(int i=2;i<n;i+=2) ans^=(aa[i]-aa[i-1]-1); } if(ans) puts("Alice"); else puts("Bob"); } return 0; }
View Code
相关文章推荐
- HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)
- Climbing the Hill - HDU 4315 阶梯博弈变形
- HDU-4315 Climbing the Hill(阶梯博弈变形)
- hdu 4315 Climbing the Hill (阶梯博弈)
- HDU 4315 Climbing the Hill(阶梯博弈)
- hdu 4315 Climbing the Hill 博弈问题,可转化为nim游戏问题,多校联合赛(二)第六题
- HDU 4315 Climbing the Hill [阶梯Nim]
- hdu - 4315 - Climbing the Hill - 博弈
- HDU 4315 Climbing the Hill Staircase Nim变种
- HDOJ 题目4315Climbing the Hill(阶梯博弈)
- hdu 4315 Climbing the Hill 博弈论
- hdu4315 Climbing the Hill(阶梯博弈)
- [HDU4315]Climbing the Hill(阶梯博弈)
- 【hdu 4315】Climbing the Hill
- HDU(2509) Be the Winner /HDU(1907) John (Nim 博弈)
- 【hdoj 4315】Climbing the Hill
- HDU 5996 NIM博弈 // 参考阶梯博弈
- HDU 2509 Be the Winner (Nim博弈)
- HDU 2509 Be the Winner && HDU 1907 John (Nim博弈变形)
- hdu 4315阶梯博弈变形