hdu 2014西安赛区网络赛 5011Game
2014-09-14 19:36
429 查看
一做网络赛就感到压力十足 挤进前90 压力山大啊。。。
Total Submission(s): 72 Accepted Submission(s): 56
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.
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.
Output
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
Sample Input
Sample Output
说是跟SG函数有关的东西 将所有的数取异或值就可以了 判断是否大于0 大于0就是Win
至于说为什么 我也不造。。
http://baike.baidu.com/view/2855458.htm?fr=aladdin SG函数
Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 72 Accepted Submission(s): 56
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.
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.
Output
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
Sample Input
1 1 2 1 1 3 1 2 3
Sample Output
Win Lose Lose
说是跟SG函数有关的东西 将所有的数取异或值就可以了 判断是否大于0 大于0就是Win
至于说为什么 我也不造。。
http://baike.baidu.com/view/2855458.htm?fr=aladdin SG函数
#include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <algorithm> #include <string.h> #include <string> #include <queue> #define eps 1e-8 #define op operator #define MOD 10009 #define MAXN 100100 #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FOV(i,a,b) for(int i=a;i>=b;i--) #define REP(i,a,b) for(int i=a;i<b;i++) #define REV(i,a,b) for(int i=a-1;i>=b;i--) #define MEM(a,x) memset(a,x,sizeof a) #define ll __int64 using namespace std; //int a[100010]; //priority_queue<int,vector<int>,less<int> > Q; int main() { //freopen("ceshi.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { int res=0; for(int i=0;i<n;i++) { int x; scanf("%d",&x); res=res^x; } if(res>0) puts("Win"); else puts("Lose"); } return 0; }
相关文章推荐
- hdu 5012 2014西安网络赛
- HDU 5015 矩阵优化 (2014西安网络赛)
- HDOJ 5012 Dice--2014网络赛西安赛区F题
- hdu 5011 Game(2014 西安网络赛)
- 2014西安赛区网络赛
- hdu 5050 Divided Land---2014acm上海赛区网络赛
- 2014西安赛区网络赛 5014 Number Sequence
- 2014网络赛 西安赛区
- 2014 ACM/ICPC 西安赛区网络赛解题报告汇总
- HDU 5008 (2014西安网络赛第二题)后缀数组
- hdu 5045 Contest--2014acm上海赛区网络赛
- hdu 5053 the Sum of Cube---2014acm上海赛区网络赛
- HDOJ 5007 Post Robot--2014网络赛西安赛区A题
- HDU 5007 Post Robot KMP (ICPC西安赛区网络预选赛 1001)
- 2014 西安赛区网络赛 5012Dice
- HDU 网络赛(杭州赛区)1003 (13.09.15)
- hdu 4731 Minimum palindrome(网络赛 成都赛区)
- hdu 4703We Love MOE Girls (2013 网络赛 成都赛区)
- 2014西安全国邀请赛 1003 && HDU 4849 Wow! Such City! (单源最短路Djikstra算法)
- hdu 4737 A Bit Fun 2013成都赛区网络赛最后一题