Problem Description

New Year is Coming! ailyanlu is very happy today! and he is playing a chessboard game with 8600.The size of the chessboard is n*n. A stone is placed in a corner square. They play alternatively with 8600 having the first move. Each time, player is allowed to move the stone to an unvisited neighbor square horizontally or vertically. The one who can't make a move will lose the game. If both play perfectly, who will win the game?
新年快到了!ailyanlu今天很开心!他正在玩8600棋盘游戏。棋盘的大小是n * n。一块石头被放置在角落广场。8600有先移动的机会。每次玩家都可以将石头水平或垂直移动到未访问的邻居广场。无法采取行动的人将失去这场比赛。如果两者都完美发挥,谁会赢得比赛?

Input

The input is a sequence of positive integers each in a separate line. 
The integers are between 1 and 10000, inclusive,(means 1 <= n <= 10000) indicating the size of the chessboard. The end of the input is indicated by a zero.
输入是一系列正整数,每个单独一行。整数在1到10000之间(表示1 <= n <= 10000),表示棋盘的大小。输入的结尾用零表示。

Output

Output the winner ("8600" or "ailyanlu") for each input line except the last zero. No other characters should be inserted in the output.
输出每个输入行的胜者(“8600”或“ailyanlu”),除了最后一个零。输出中不应插入其他字符。

Sample Input

2
0

Sample Output

8600
解题思路:找规律博弈。题目的意思就是轮到的人只能上或下或左或右移1格到未访问的格子,并且两者完美发挥,最后无法移动的人将输掉比赛。
举3个栗子:①当n=1(奇数)时,先手不能移动,则后手必赢;
②当n=2(偶数)时,两者移动如图所示(都是最优策略):易得先手必赢
③当n=3(奇数)时,两者移动如图所示(都是最优策略):易得后手必赢
再举多个例子的过程中我们可以发现:当n为奇数时,后手只要按照螺旋线的走法(最优策略),最后一步必到中心方格,此时先手无法再移动,即后手必赢;当n为偶数时,同样,按照螺旋线的走法(最优策略),最后一步必轮到先手,此时后手无法移动,即先手必赢。
因此,可得出结论:当n为奇数时,“8600”先手必赢;反之,“ailyanlu”后手必赢。
AC代码:
 #include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin>>n && n){
if(n%==)cout<<""<<endl;//先手必赢
else cout<<"ailyanlu"<<endl;//后手必赢
}
return ;
}

题解报告:hdu 1564 Play a game(找规律博弈)的更多相关文章

  1. HDU 3032 multi-sg 打表找规律

    普通NIM规则加上一条可以分解为两堆,标准的Multi-SG游戏 一般Multi-SG就是根据拓扑图计算SG函数,这题打表后还能发现规律 sg(1)=1 sg(2)=2 sg(3)=mex{0,1,2 ...

  2. HDU 5793 A Boring Question (找规律 : 快速幂+乘法逆元)

    A Boring Question Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  3. hdu 1030 Delta-wave(数学题+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...

  4. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  5. HDU 4910 Problem about GCD 找规律+大素数判断+分解因子

    Problem about GCD Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. HDU 4572 Bottles Arrangement(找规律,仔细读题)

    题目 //找规律,123321123321123321…发现这样排列恰好可以错开 // 其中注意题中数据范围: M是行,N是列,3 <= N < 2×M //则猜测:m,m,m-1,m-1 ...

  7. HDU 1041 Computer Transformation(找规律加大数乘)

    主要还是找规律,然后大数相乘 #include<stdio.h> #include<string.h> #include<math.h> #include<t ...

  8. HDU 1391 number steps(找规律,数学)

    Starting from point (0,0) on a plane, we have written all non-negative integers 0, 1, 2,... as shown ...

  9. HDU 4731 Minimum palindrome (找规律)

    M=1:aaaaaaaa…… M=2:DFS+manacher, 暴出N=1~25的最优解,找规律.N<=8的时候直接输出,N>8时,头两个字母一定是aa,剩下的以aababb循环,最后剩 ...

随机推荐

  1. kata练习题

    This time no story, no theory. The examples below show you how to write function accum: Examples: ac ...

  2. Shock wave

    ** shock wave thickness of shock wave is order of 1e-7 m why governed by Euler Equation? P334 shock ...

  3. PAT 1141 PAT Ranking of Institutions

    After each PAT, the PAT Center will announce the ranking of institutions based on their students' pe ...

  4. saltstack(二) master、minion常用配置选项

    master常用配置选项: interface: 指定bind的地址(默认0.) publish_port:指定发布端口(默认4505) ret_port: 指定结果返回端口,与minion配置文件的 ...

  5. 我安装android studio的过程与经历

    虽然android studio已经出来两年多了,但是我一直都没真正用过.之前用Eclipse还算用得挺好.我并不是一个专职的android开发者,我是个游戏开发者,打包的时候要用到android.不 ...

  6. 这个函数有搞头,要调试通过就差不多啦--ImpersonateActiveUserAndRun

    //Function to run a process as active user from windows service void ImpersonateActiveUserAndRun() { ...

  7. 常见mysql的数据迁移

    1.处理把A表中的部分列复制到B表中主要处理同一库. UPDATE T_EVENT EVE, T_IPMAP MAP SET EVE.c_staff_code = MAP.c_staff_code, ...

  8. js 最简单的实现复制到剪切板 xl_copy

    使用 npm install xl_copy // 项目中安装 import clipboard form 'xl_copy' // 引用 element.onclick = ()=>{     ...

  9. js事件捕获和冒泡解析

    <div id="box"> <div id="box2"> <p id="test">test< ...

  10. Linux Rsync实现文件同步备份(转载)

    原文地址:Linux Rsync实现文件同步备份作者:夷北 转自:http://www.mike.org.cn/blog/index.php?load=read&id=639###pp=0 [ ...