Problem:
There are n bottles and one prize. players need to guess which bottle the prize belongs.
There are n black bottles (so that the game can't see whether there is anything in the bottle) from 0 to n-1 number, one line open.
If a gamer guesses a mistake, the prize will be moved to the left or right bottle with a probability of 50%.
When the prize is on the leftmost or rightmost side and the gamer guesses the mistake, the prize must be shifted to or left.
How many times do gamers have to guess the prize location.
PS: It seems like a Netease game interview question, which is interesting.
Analysis:
At first glance, it seems like there is no solution, and it is impossible to guess. This is also interesting.
Assume 8 bottles, 1.2.3.4.5.6.7.8
1) assume that the prize is in an odd number, for example, in 3.
First in order to point, 1 point once, no point 2, 1 point to the end, that is, 8 times.
No, the prize is even. Point 2, no, the prize is odd and cannot be 1. To change 1, you must pass 2, but 2 does not.
Therefore, the prize is an odd number after 3 or 3. Now at, if there is no prize, it is changed to an even number and cannot be 2. The reason is the same.
In this way, the prize will surely be found at the end of the order. If it is not found, the assumption is not true. The prize is initially in an even number.
2) assume that the prize is in an even number, for example, in 4.
Then we can start from 2. The principle is the same as above. We can certainly find it. Otherwise, the assumption is not true.
Scan twice to find the prize!