[原博客] POJ 2484 A Funny Game

时间:2023-03-09 19:28:26
[原博客] POJ 2484 A Funny Game

题目链接
题意:有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);
);
int n;
int main(){
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    while(scanf("%d",&n),n){
        ){
            puts("Bob");
        }else puts("Alice");
    }
    ;
}