hdu1564 Play a game【博弈 找规律】

来源:互联网 发布:中英文转换器软件 编辑:程序博客网 时间:2024/06/08 10:09

传送门:hdu1564

又是蛋疼的找规律,只会打表。。。胜负和奇偶性有关
证明参考:
HDU 1564 Play a game (找规律博弈) - kuangbin - 博客园 这篇感觉好懂点
hdu 1564 证明 - coder notebook - 博客频道 - CSDN.NET 还没看懂。。

#include <cstdio>int main(){    int n;    while(scanf("%d", &n), n)        puts(n&1?"ailyanlu":"8600");    return 0;}
//打表代码const int MAXN = 10010;bool visit[MAXN][MAXN];int nx[4] = {0, 1, 0, -1}, ny[4] = {1, 0, -1, 0};int n;bool dfs(int x, int y){    for(int i = 0; i < 4; i++)    {        int tx = x + nx[i];        int ty = y + ny[i];        if(tx < 1 || tx > n || ty < 1 || ty > n)            continue;        if(!visit[tx][ty])        {            visit[tx][ty] = true;            bool flag = dfs(tx, ty);            visit[tx][ty] = false;            if(!flag)                return true;        }    }    return false;}
0 1