码迷,mamicode.com
首页 > 其他好文 > 详细

BZOJ2463 谁能赢呢?

时间:2016-07-23 00:27:44      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

Description

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

Input

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

 

Output

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

Sample Input

2
0

Sample Output

Alice

HINT

 

对于所有的数据,保证1<=n<=10000。
 
 
 
正解:博弈
解题报告:
  最简单的题目,没有之一。
 
 1 //It is made by jump~
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cmath>
 5 #include<cstring>
 6 #include<cstdlib>
 7 #include<algorithm>
 8 #include<vector>
 9 using namespace std;
10 int n;
11  
12 inline int getint(){
13     char c=getchar(); int w=0,q=0;
14     while(c!=- && ( c<0 || c>9)) c=getchar();
15     if(c==-) c=getchar(),q=1;
16     while(c>=0 && c<=9) w=w*10+c-0,c=getchar();
17     return q?-w:w;
18 }
19  
20 inline void work(){
21     while(1) {
22     n=getint();
23     if(n==0) break;
24     if(n&1) printf("Bob\n"); else printf("Alice\n");
25     }
26 }
27  
28 int main()
29 {
30     work();
31     return 0;
32 }

 

BZOJ2463 谁能赢呢?

标签:

原文地址:http://www.cnblogs.com/ljh2000-jump/p/5697485.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!