题意是n枚硬币排一个圈,Alice和Bob轮流取,一次可以取一枚或连续的两枚,已取走的硬币左右硬币不算相连,Alice先走,输出赢家。
思路:本题就是一种对称的思路,我们首先可以证明相同的两列是必败态,因为你无论取什么,对手不断模仿你就行。
本题中Alice无论第一次取什么,Bob都可以取走1或2枚使得硬币形成相同的两列;特例是n<= 2 , Alice一次取完的情况。
#include <cstdio> #include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <map> #include <string> #include <stack> #include <cctype> #include <vector> #include <queue> #include <set> #include <utility> #include <cassert> using namespace std; ///#define Online_Judge #define outstars cout << "***********************" << endl; #define clr(a,b) memset(a,b,sizeof(a)) #define lson l , mid , rt << 1 #define rson mid + 1 , r , rt << 1 | 1 #define mk make_pair #define FOR(i , x , n) for(int i = (x) ; i < (n) ; i++) #define FORR(i , x , n) for(int i = (x) ; i <= (n) ; i++) #define REP(i , x , n) for(int i = (x) ; i > (n) ; i--) #define REPP(i ,x , n) for(int i = (x) ; i >= (n) ; i--) const int MAXN = 15 + 5; const int MAXS = 10000 + 50; const int sigma_size = 26; const long long LLMAX = 0x7fffffffffffffffLL; const long long LLMIN = 0x8000000000000000LL; const int INF = 0x7fffffff; const int IMIN = 0x80000000; const int inf = 1 << 30; #define eps 1e-10 const long long MOD = 1000000000 + 7; const int mod = 10007; typedef long long LL; const double PI = acos(-1.0); typedef double D; typedef pair<int , int> pii; typedef vector<int> vec; typedef vector<vec> mat; #define Bug(s) cout << "s = " << s << endl; ///#pragma comment(linker, "/STACK:102400000,102400000") int main() { int n; while(~scanf("%d" , &n) , n) { if(n <= 2)puts("Alice"); else puts("Bob"); } return 0; }