Topic Link: Click to open the link
Test instructions: N number of numbers 1-n around a ring, two people take turns, each time can only take the adjacent two or only one, can not take the loser.
Consider such a problem, if it is not a ring but a line, that is, from the 1-n into a row, so that the initiator just take the middle of the two or a composition of the number of equal (left and right symmetry), then the initiator can be invincible (simply speaking, regardless of which side the opponent takes, The initiator can win as long as it is taken in the same way on the other side.
But this problem is a ring, consider the special case, when the length of the ring is less than 3 when the initiator win (directly all take), but greater than or equal to 3, any one can break the ring as the line (chain), and then because the line when the initiator wins, so the answer is the initiator will be defeated.
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 10000002#define _ll __int64# Define ll long long#define INF 0x3f3f3f3f#define Mod 10000007#define pp pair<int,int> #define ull unsigned long Longu Sing namespace Std;int n;int main () {while (scanf ("%d", &n) &&n) { if (n<3) puts ("Alice"); else puts (" Bob ");} return 0;}
POJ 2484-a Funny Game (symmetric game)