zoukankan      html  css  js  c++  java
  • BZOJ 2463: [中山市选2009]谁能赢呢?(智商)

    Time Limit: 10 Sec  Memory Limit: 128 MB
    Submit: 3110  Solved: 2250
    [Submit][Status][Discuss]

    Description

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

    Input

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

    Output

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

    Sample Input

    2
    0

    Sample Output

    Alice

    HINT

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

    Source

     
    第三遍做这道题了233
    结论都快背过了。
    直接判断奇偶性即可
     
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    const int MAXN=1e5+10,mod=10007;
    inline char nc()
    {
        static char buf[MAXN],*p1=buf,*p2=buf;
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXN,stdin)),p1==p2?EOF:*p1++;
    }
    inline int read()
    {
        char c=nc();int x=0,f=1;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=nc();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=nc();}
        return x*f;
    }
    int a[MAXN];
    int main()
    {
        #ifdef WIN32
        freopen("a.in","r",stdin);
        #else
        #endif
        int N;
        while(1)
        {
            N=read();
            if(N==0) break;
            if(N&1) printf("Bob
    ");
            else     printf("Alice
    ");
        }
        return 0;
    }
  • 相关阅读:
    论文摘要
    memset/memcpy/strcpy
    error C2259: 'CException' : cannot instantiate abstract class解决
    IplImage 结构
    图像的深度和通道概念
    Oracle11g安装教程
    LSTM理解
    卷积神经网络CNN
    常见激活函数的介绍和总结
    TFIDF算法介绍
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/8471371.html
Copyright © 2011-2022 走看看