HDU 5011 Game 【Nim博弈】
来源:互联网 发布:怎么添加打印机端口 编辑:程序博客网 时间:2024/05/20 18:55
Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 520 Accepted Submission(s): 394
Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. Each turn, player choose a pile i and remove some (at least one) beads from it. Then he could do nothing or split pile i into two piles with a beads and b beads.(a,b > 0 and a + b equals to the number of beads of pile i after removing)
● If after a player's turn, there is no beads left, the player is the winner.
Suppose that the two players are all very clever and they will use optimal game strategies. Your job is to tell whether the player who plays first can win the game.
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. Each turn, player choose a pile i and remove some (at least one) beads from it. Then he could do nothing or split pile i into two piles with a beads and b beads.(a,b > 0 and a + b equals to the number of beads of pile i after removing)
● If after a player's turn, there is no beads left, the player is the winner.
Suppose that the two players are all very clever and they will use optimal game strategies. Your job is to tell whether the player who plays first can win the game.
Input
There are multiple test cases. Please process till EOF.
For each test case, the first line contains a postive integer n(n < 105) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer ai(ai < 231) means there are ai beads in the i-th pile.
For each test case, the first line contains a postive integer n(n < 105) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer ai(ai < 231) means there are ai beads in the i-th pile.
Output
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
Sample Input
1121 131 2 3
Sample Output
WinLoseLose
#include<cstdio>int main(){int t,n,m;while(scanf("%d",&n)!=EOF){scanf("%d",&m);t=m;for(int i=1; i<n; i++){scanf("%d",&m);t^=m;}if(t==0) printf("Lose\n");else printf("Win\n");}return 0;}
0 0
- HDU 5011 Game nim博弈
- HDU 5011 Game 【Nim博弈】
- HDU 5011 Game(Nim博弈)
- HDU 5011Game-多个堆的NIM博弈
- hdu 1730 Northcott Game (nim博弈变形)
- HDU 1730 Northcott Game(nim博弈)
- hdu 1730 Northcott Game Nim博弈~~
- HDU 3389 Game(博弈 Nim 找规律)
- hdu 1730 Northcott Game (Nim博弈)
- HDU 3389 Game(博弈 Nim 找规律)
- HDU 3915 Game NIM博弈 XOR高斯消元
- HDU 3389 Game(nim博弈)
- HDU 1730 Northcott Game (Nim博弈)
- hdu 5011 (nim博弈模版)
- hdu 5011 nim博弈变形
- Northcott Game + nim博弈
- hdu3389 Game NIM博弈
- hdu1730Northcott Game NIM博弈
- poj 2243 Knight Moves
- UVA - 10801 Lift Hopping (Dijkstra)
- 容器 第二节 重写equals和hashCode方法
- hibernate之13.hql(二)
- GitHub 优秀的 Android 开源项目
- HDU 5011 Game 【Nim博弈】
- codeforces 476c Dreamoon and Sums
- opengl教程
- CodeForces 486C Palindrome Transformation
- libevent2源码 min_heap
- Uva 644-Immediate Decodability(串)
- 备份基本原理
- C++ STL删除元素的一些案例
- 【树套树】【bzoj 3236】: [Ahoi2013]作业