题目链接:http://poj.org/problem?id=2484
题目大意:一个圈的n个珠子,可以一次取走一个或者两个连续的。先取完者获胜。注意:有三个连续了,取走中间的,那么剩下两个算不连续的。
解:n<=2的时候先手胜。
n>2的时候,对于任意一个环,先手取完后,后者总能够取走一定某个位置的一个或者两个珠子,使得它变成两个完全相同的串。也就是后者总能够创造出成对匹配的串,这样后者必赢。
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int main () {
int n;
while (scanf("%d", &n) != EOF, n) {
if(n > 2) {
printf("Bob\n");
}
else {
printf("Alice\n");
}
}
return 0;
}