AC日记——[中山市选2009]谁能赢呢? bzoj 2463

2463

思路:

  博弈;

  把先手和后手的走的两个格子看做一个1*2的方格;

  如果n为偶数,那么棋盘一定可以被1*2的方格覆盖;

  前端为先手,后端为后手;

  那么,当还剩下一个1*2的方格时,先手一定可以走,而后手不能;

  所以先手必胜;

  当n为奇数时,反之;

来,上代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int n;

inline int R()
{
    int now=0;char Cget=getchar();
    while(Cget>'9'||Cget<'0') Cget=getchar();
    while(Cget>='0'&&Cget<='9')
    {
        now=now*10+Cget-'0';
        Cget=getchar();
    }
    return now;
}

int main()
{
    while(n=R()) n&1?printf("Bob
"):printf("Alice
");
    return 0;
}
原文地址:https://www.cnblogs.com/IUUUUUUUskyyy/p/6741736.html