I am stucked in solving one problem.
The problem is below.
DESCRIPTION :
Alice and Bob are playing a game. First, they define $N$($N$ is natural number), and a number '$x$'(initiated to 1) is given. Alice will play first, and they play alternatively. In each turn, they play the work below.
[WORK]
substitute $x$ to $2x$ or $2x+1$.
if x>N, the player who played the work lose.
For example,
if $N=1$, Alice loses because $2>N, 3>N$.
if $N=2$, if Alice choose $2x$, then $x$ will be 2, So, Bob loses.
if $N=3$, if Alice choose $2x+1$, then $x$ will be 3, So, Bob loses.
if $N=4$, if Alice choose $2x+1$, then $x$ will be 3, So, Bob loses.
if $N=5$, if Alice choose $2x+1$, then $x$ will be 3, So, Bob loses.
Then, if N is given, how can we know who is winner?
I tried some approaches such as balanced binary tree, dynamic programming, etc.
I get an insight that if $N=2^m-1$, if $m$ is even, first player 'Alice' will win, and in other case, 'Bob' will win.
But I couldn't get more insights. Can anyone help me have a insight to this question?
Really amusing problem.
The answer can be written in a lot of ways, so the one I'll expose is probably not the best one:
Let $$x = 3N+5, \qquad z = \lfloor\log_4(x)\rfloor.$$
Then Bob wins if and only if $$5\cdot 4^{z-1}<x\le 2\cdot 4^{z}$$
Proof:
The idea to prove it is common to many games of the kind, that is to divide the number $1,2,\dots,N$ between "loser"(L) and "winner"(W) numbers. For example, if it is Alice's turn, and she gets the number $N$, then she loses, so $N$ is a loser number.
It's easy to see that the numbers from $N$ to $\lceil (N+1)/2\rceil$ are loser numbers, since if you multiply them by 2, you get a number $>N$. If you call $M=\lceil (N+1)/2\rceil$, then you find that the numbers from $M-1$ to $\lfloor M/2\rfloor$ are W, since there exists a move that bring them to a L number.
Given a specified $N$, and applying the reasoning above til you get to 1, you find that Alice wins if and only if 1 is a W number. In particular, it holds that
So the whole problem is reduced to find all the $N$ for which we get 1 for the first time after an even number of iterations.
After a bit of meddling, you will see that the number 1 starts to be W when $N$ is in the form $4^{n} + \frac 53 (4^{n}-1) +1$ and starts to be L when $N$ is in the form $\frac 53 (4^{n}-1) +1$.
This means that Bob wins when $$ \frac 53 (4^{n}-1) < N \le 4^{n} + \frac 53 (4^{n}-1) $$ $$ 5\cdot 4^{n} < 3N + 5 \le 8\cdot 4^{n} = 2 \cdot 4^{n+1} $$ but we have that $$ 4^{n+1} < 5\cdot 4^{n} < 3N + 5 \le 8\cdot 4^{n} = 2 \cdot 4^{n+1} < 4^{n+2} $$ so $\lfloor\log_4(3N+5)\rfloor = n+1$ and this coincides with the formula above.