2020 cattle off the base algorithm winter training camp 5 E Enjoy the game

https://ac.nowcoder.com/acm/contest/3006/E

Title Description

Taurus team three players in the training apart from his own mouth Hu will be some questions as usual puzzle game. One day cattle Coke came up with a game to play with two other players, rules of the game are as follows:

  • A total initial ncard card
  • Just get a minimum first step to bring a card, bring it up to n-1cards.
  • Then every step, at least two sides to bring 1cards, equivalent to the previous step up to take the license number of the other party to take the cards.
  • Who took the last card will win the game.

You, as a spectator, watching them playing very happy, want to participate in this game, who will take a risk to win.

Thinking

I am too weak to game theory, thanks to hit the table to find the law

Integer power of 2, when is doomed to failure, the output Alice, Bob remaining output

/*************************************************************************
    > File Name: E.cpp
    > Author: amoscykl
    > Mail: [email protected]
    > Created Time: 2020年02月13日 星期四 14时17分15秒
 ************************************************************************/
 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    scanf("%lld", &n);
    bool f = 0;
    ll t = 2;
    while (t < n){
        t <<= 1;
    }
    if (t == n)f = 1;
    printf(f ? "Alice" : "Bob");
    return 0;
}

 

Published 204 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43701790/article/details/104308633