对称博弈 POJ 2484

如果n=1先手必胜,n=2先手必胜
然后考虑一条线的情况,先手把这些硬币从中间取走1或2个使得左右两堆数目相等,然后对方从哪堆中取多少,自己就从另一堆中取相应的个数
因为这是一个环所以n>=3时先手必败


代码如下:

#include
#include
#include
#include
using namespace std;
signed main(void){
    int n;
    while(scanf("%d",&n)&&n){
        if(n<3)
            cout<<"Alice"<else
            cout<<"Bob"<return 0;
}

by >o< neighthorn

你可能感兴趣的:(poj题解,模板,数学)