标签:style blog http color os io ar strong art
题目链接
题意:有n个硬币排成一圈,两个人轮流操作,每次可以取走一个或者相邻的连个硬币(只算最开始相邻的,取之后才相邻的不算),问先手必胜还是必败。
这个题可以证明若n>=3
,则先手必败。
对称博弈
若n>=3
,先手第一次必然把这个环拆成一个链,然后无论这条链长度的奇偶,后手总是可以把这条链分成两条相等的链,于是先手在一条链上做什么,后手就可以做什么。知道先手无法操作,后手胜。
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> //by zrt //problem: using namespace std; typedef long long LL; const int inf(0x3f3f3f3f); 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; }
标签:style blog http color os io ar strong art
原文地址:http://www.cnblogs.com/zrts/p/3960976.html