Question Link
Meaning: There are n coins in a circle, and two people take turns to take one or more adjacent coins each time (only the first and last adjacent coins are counted ), ask if the first hand wins or loses.
This question proves thatN> = 3
, The first hand will be defeated.
Symmetric game
IfN> = 3
For the first time, the first hand must split the ring into a chain. No matter the parity of the chain length, the latter hand can always divide the chain into two equal chains, so what does the first hand do on a chain, what can be done later. Knowing that the first hand cannot be operated, the second hand wins.
# Include <iostream> # include <cstdio> # include <algorithm> # include <cstring> // By Zrt // problem: Using namespace STD; typedef long ll; const int Inf (0x3f3f3f); const double EPS (1e-9); int N; int main () {# ifdef local freopen ("in.txt", "r", stdin ); freopen ("out.txt", "W", stdout); # endif while (scanf ("% d", & N), n) {If (n> = 3) {puts ("Bob");} else puts ("Alice");} return 0 ;}
View code
[Original blog] poj 2484 a funny game