Cattle passenger Enjoy the game (Game Theory)

Topic Link

The initial a total of n cards cards
just get at least a first step to bring a card, bring it up to n-1 cards.
Then each step, the two sides at least bring a brand, get the most equal to the number of cards on the card to get the other side of the step.
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.

Enter a description:

The input data includes an integer n ( 2 n 1 0 18 n (2 \ leq n \ leq 10 ^ {18} ), indicates the number of a card's initial card.

Output Description:

If you have the upper hand winning strategy, output Bob, otherwise the output Alice.


Odd win the upper hand, and simulate even, when n is a power of 2 x when the upper hand will lose.
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<list>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
#define N 100007
int mod = 1e9+7;
int main(){    
    ll n;
    cin >> n;
    ll tmp = 2;
    for(int i=1;i<=60;i++){
    	if(tmp==n){
    		cout << "Alice" << endl;
    		return 0;
		}
		tmp = tmp*2;
	}
	cout << "Bob" << endl;
    return 0;
}
Published 79 original articles · won praise 37 · views 8876

Guess you like

Origin blog.csdn.net/SinclairWang/article/details/104302429