小明和小红经常玩一个博弈游戏。给定一个n×n的棋盘,一个石头被放在棋盘的左上角。他们轮流移动石头。每一回合,选手只能把石头向上,下,左,右四个方向移动一格,并且要求移动到的格子之前不能被访问过。谁不能移动石头了就算输。假如小明先移动石头,而且两个选手都以最优策略走步,问最后谁能赢?
标签:棋盘 string bbs 表示 不能 答案 space code inpu
对于每组数据,如果小明最后能赢,则输出”Alice”, 否则输出”Bob”, 每一组答案独占一行。
/* * Author: lyucheng * Created Time: 2017年05月14日 星期日 15时53分23秒 * File Name: BZOJ-2463.cpp */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <time.h> using namespace std; int n; int main(int argc, char* argv[]) { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout; while(scanf("%d",&n)!=EOF&&n){ if(n*n%2==1){ puts("Bob"); }else{ puts("Alice"); } } return 0; }
标签:棋盘 string bbs 表示 不能 答案 space code inpu
原文地址:http://www.cnblogs.com/wuwangchuxin0924/p/6852774.html