• BZOJ2463 谁能赢呢?


    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
    "); else printf("Alice
    ");
    25     }
    26 }
    27  
    28 int main()
    29 {
    30     work();
    31     return 0;
    32 }
  • 相关阅读:
    pop指令的执行过程
    ipad 4.2 开发环境
    XP远程桌面
    停机问题、哥德尔定理
    看MIT的线性代数
    VizA项目继续推进
    port systemc to mac os x
    关于jar
    普桑
    拉突爾
  • 原文地址:https://www.cnblogs.com/ljh2000-jump/p/5697485.html
Copyright © 2020-2023  润新知