bzoj2463 [中山市选2009]谁能赢呢?

Description

小明和小红经常玩一个博弈游戏。给定一个n×n的棋盘,一个石头被放在棋盘的左上角。他们轮流移动石头。每一回合,选手只能把石头向上,下,左,右四个方向移动一格,并且要求移动到的格子之前不能被访问过。谁不能移动石头了就算输。假如小明先移动石头,而且两个选手都以最优策略走步,问最后谁能赢?

Input

    输入文件有多组数据。
    输入第一行包含一个整数n,表示棋盘的规模。
    当输入n为0时,表示输入结束。
 

Output

对于每组数据,如果小明最后能赢,则输出”Alice”, 否则输出”Bob”, 每一组答案独占一行。

Sample Input

2
0

Sample Output

Alice

HINT

对于所有的数据,保证1<=n<=10000。

 

正解:博弈论。

傻逼题。。打表易得偶赢奇输。

证明:$n$为偶数时必能被$2*1$的骨牌覆盖满,所以先手赢。而$n$为奇数时先手走一步以后棋盘必能被$2*1$的骨牌覆盖满,所以后手赢。

 

 1 //It is made by wfj_2048~
 2 #include <algorithm>
 3 #include <iostream>
 4 #include <complex>
 5 #include <cstring>
 6 #include <cstdlib>
 7 #include <cstdio>
 8 #include <vector>
 9 #include <cmath>
10 #include <queue>
11 #include <stack>
12 #include <map>
13 #include <set>
14 #define inf (1<<30)
15 #define il inline
16 #define RG register
17 #define ll long long
18 #define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
19 
20 using namespace std;
21 
22 int n;
23 
24 il int gi(){
25     RG int x=0,q=1; RG char ch=getchar();
26     while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
27     if (ch=='-') q=-1,ch=getchar();
28     while (ch>='0' && ch<='9') x=x*10+ch-48,ch=getchar();
29     return q*x;
30 }
31 
32 int main(){
33     File("who");
34     while (n=gi(),n)
35     puts(n&1 ? "Bob" : "Alice");
36     return 0;
37 }

 

posted @ 2017-03-30 14:43  wfj_2048  阅读(130)  评论(0编辑  收藏  举报