hdoj 5011 Game(基础尼姆博弈)
2014-11-06 18:52
134 查看
http://acm.hdu.edu.cn/showproblem.php?pid=5011
Total Submission(s): 505 Accepted Submission(s): 386
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
[align=left]Sample Input[/align]
1
1
2
1 1
3
1 2 3
[align=left]Sample Output[/align]
Win
Lose
Lose
Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 505 Accepted Submission(s): 386
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
[align=left]Sample Input[/align]
1
1
2
1 1
3
1 2 3
[align=left]Sample Output[/align]
Win
Lose
Lose
#include<stdio.h> int main() { int N,i,j,k,sum; while(scanf("%d",&N)!=EOF) { for(i=0,sum=0;i<N;i++) { scanf("%d",&k); sum^=k; } if(sum!=0) printf("Win\n"); else printf("Lose\n"); } return 0; }
相关文章推荐
- hdoj 1034 Candy Sharing Game【基础题】&&【关键是理解题意】
- HDU 5011-Game(尼姆博弈)
- HDOJ 5011 Game
- hdoj 1849 Rabbit and Grass(基础尼姆博弈)
- HDOJ 2999 Stone Game, Why are you always there? 博弈 SG函数
- [HDOJ 1056] HangOver (基础题)
- HDOJ-1253 基础搜索问题总结[DFS()+BFS()]
- hdoj 4203 Doubloon Game(博弈+找规律)
- [HDOJ 1039] Easier Done Than Said? (基础,字符串) .
- 使用MIDP2.0开发游戏(1)GameCanvas基础
- HDOJ 4203 Doubloon Game 博弈 找规律
- HDOJ 2177 取(2堆)石子游戏 博弈 威佐夫博奕变形(Wythoff Game)
- HDOJ 2147 kiki’s game
- unity基础开发----切换场景、游戏视图(Game View)、iphone优化
- HDOJ 1134 Game of Connections 简单解题报告
- hdoj1829 基础并查集
- GameEngine 基础入门 c++
- hdoj 1134 Game of Connections【水】【java】
- HDOJ 3389 Game (博弈:Staircase Nim)
- 读 Beginning Android Games 2nd Edition (十二) 把框架基础功能放入Game类中