hdu 5011 Game Nim博弈 2014 ACM/ICPC Asia Regional Xi'an Online
来源:互联网 发布:mysql 数据库文件类型 编辑:程序博客网 时间:2024/05/01 14:54
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5011
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
Source
2014 ACM/ICPC Asia Regional Xi'an Online
代码:
#include <algorithm>#include <cstdlib>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <cctype>#include <cmath>#include <stack>#include <queue>#include <list>#include <map>#include <set>using namespace std;#define min2(x, y) min(x, y)#define max2(x, y) max(x, y)#define min3(x, y, z) min(x, min(y, z))#define max3(x, y, z) max3(x, max(y, z))#define clr(x, y) memset(x, y, sizeof(x))#define fr(i,n) for(int i = 0; i < n; i++)#define fr1(i,n) for(int i = 1; i < n; i++)#define upfr(i,j,n) for(int i = j; i <= n; i++)#define dowfr(i,j,n) for(int i = n; i >= j; i--)#define scf(n) scanf("%d", &n)#define ptf(n) printf("%d",n)#define ptfs(s) printf("%s",s)#define ptln() printf("\n")#define srt(a,n) sort(a,n)#define LL long long#define pi acos(-1.0)#define inf 1 << 31-1#define eps 0.00001#define maxn 100005int main(){ int n; while(scf(n) != EOF) { int k; __int64 ans = 0; fr(i,n) { scf(k); ans = ans ^ k; } if(!ans) printf("Lose\n"); else printf("Win\n"); } return 0;}
0 0
- hdu 5011 Game Nim博弈 2014 ACM/ICPC Asia Regional Xi'an Online
- 2014 ACM/ICPC Asia Regional Xi'an Online 小记
- 2014 ACM/ICPC Asia Regional Xi'an Online
- 2014 ACM/ICPC Asia Regional Xi'an Online(hdu 5007 - hdu 5017)
- hdu 5015 233 Matrix 2014 ACM/ICPC Asia Regional Xi'an Online 矩阵快速幂
- hdu 5012 Dice 2014 ACM/ICPC Asia Regional Xi'an Online bfs
- hdu 5014 Number Sequence 2014 ACM/ICPC Asia Regional Xi'an Online 数论
- HDU 5014 Number Sequence 贪心 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 1009 233 Matrix 矩阵构造 --2014 ACM/ICPC Asia Regional Xi'an Online
- HDU 5015 233 Matrix / 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5014 Number Sequence 找规律 | 贪心 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5008(2014 ACM/ICPC Asia Regional Xi'an Online ) Boring String Problem(后缀数组&二分)
- hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
- 2014 ACM/ICPC Asia Regional Xi'an Online 233 Matrix,hdu 5015
- hdu 5012 Dice BFS 2014 ACM/ICPC Asia Regional Xi'an Online
- HDU5014(异或) HDU 5012(BFS)(2014 ACM/ICPC Asia Regional Xi'an Online)题解
- hdu 5009 Paint Pearls 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5015 233 Matrix 矩阵快速幂 2014 ACM/ICPC Asia Regional Xi'an Online
- ubuntu下如何编译C语言
- c#解析xml绑定treeview控件实现
- lucms结构
- 俄罗斯方块(C语言版)
- signal()函数
- hdu 5011 Game Nim博弈 2014 ACM/ICPC Asia Regional Xi'an Online
- 一个俄罗斯方块的源代码
- HDU-#5011 Game(Nim和)
- JavaScript中引用外部CSS文件
- HDU5017(2014年西安网络赛K题)
- 【机房收费系统】上下机分析
- ubuntu14.04 安装phpmyadmin 和配置
- 2014西安网络预选赛1009(矩阵快速幂)hdu5015
- LaTeX/Algorithms 伪代码