Game HDU - 5011

原创 2018年04月16日 16:19:29

异或运算

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 < 10 5) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer a i(a i < 2 31) means there are a i 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

#include<stdio.h>

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int a,x=0;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a);
            x^=a;
        }
        if(!x)
            printf("Lose\n");
        else
            printf("Win\n");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/we1215053460/article/details/79962216

HDU5011:Game(博弈)

Problem Description Here is a game for two players. The rule of the game is described below:  ...
  • libin56842
  • libin56842
  • 2014-09-15 20:24:22
  • 1801

HDU—— 5011 Game

题意:简单的Nim游戏,两个人轮流拿
  • u014086857
  • u014086857
  • 2014-09-28 10:40:43
  • 296

hdu 5011 Game

Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Sub...
  • u010650359
  • u010650359
  • 2014-09-15 19:14:17
  • 950

HDU5011-Game(博弈)

题目链接 题意:取石子游戏,两个人轮流取石子,取石子有规则,要么那掉这堆石子,要么将这堆石子分成两堆,在加入原来的石堆当中,先手取完算胜利,否则失败。 思路:简单的Nim游戏,...
  • u011345461
  • u011345461
  • 2014-09-15 00:12:17
  • 1182

hdu 5011 Game【尼姆博弈】

Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total S...
  • mengxiang000000
  • mengxiang000000
  • 2016-07-29 17:49:13
  • 347

[博弈] hdu 5011 Game

题意:n堆东西,每次至少取一个,取完可以把这堆剩下的分成
  • wdcjdtc
  • wdcjdtc
  • 2014-09-16 17:08:00
  • 483

hdu 5011 Game(博弈)

题目链接:hdu 5011 Game 题目大意:n堆石子,两人轮流取,每次取完可以将剩下的石子分成若干份。取到最后一个石子的人胜利。 解题思路:Nim和为0则为N态,否则为P态。 #in...
  • u011328934
  • u011328934
  • 2014-09-15 19:17:40
  • 483

hdu 5011 Game 博弈

这道题目以前做过,其实就是一个nim游戏 Description Here is a game for two players. The rule of the game is de...
  • u013087645
  • u013087645
  • 2015-02-05 16:25:48
  • 404

HDU 5011-Game(尼姆博弈)

Game Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Pr...
  • u013486414
  • u013486414
  • 2015-03-11 20:32:29
  • 565

HDU 5011 Game(尼姆博弈)

Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Sub...
  • yeguxin
  • yeguxin
  • 2015-03-17 20:59:42
  • 503
收藏助手
不良信息举报
您举报文章:Game HDU - 5011
举报原因:
原因补充:

(最多只允许输入30个字)