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. 斯特林公式 hdu1018

    杭电上面1018>>点击测试<< 思路:当问到阶乘的值时候,用万进制来写:但是问阶乘值的位数的时候,就可以用斯特林公式了 log10(2*pi*n)/2+n*log10(n/e ...

  2. UVALive 7008 Tactical Multiple Defense System

     Tactical Multiple Defense System Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld &a ...

  3. 自定义EL表达式,将对象转成json格式,关键代码

    做javaweb开发的最常用的一个东西el表达式,这个东西是个很好用的东西,但有些时候我们处理复杂的字符串操作,就有些相形见绌了,这个时候就需要用自定义的方法去实现更多简洁方便的事情. 下面自定义一个 ...

  4. Truck History(卡车历史)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 26547   Accepted: 10300 Description Adv ...

  5. 【UOJ34】高精度乘法(FFT)

    题意: 思路:FFT模板,自带10倍常数 type cp=record x,y:double; end; arr=..]of cp; var a,b,cur:arr; n,m,n1,n2,i,j:lo ...

  6. Spring——ClassPathXmlApplicationContext(配置文件路径解析 1)

    ClassPathXmlApplicationContext     在我的 BeanFactory 容器文章中主要提及了 BeanFactory 容器初始化(Spring 配置文件加载(还没解析)) ...

  7. 分析helo1项目中的 Web.xml

    web.xml文件位于hello1 中target/WEB-INF/classes/javaeetutorial目录下. 这个web.xml文件包含Facelets应用程序所需的几个元素: 其中(1) ...

  8. Ubuntu 16.04设置开机启动应用程序

    在终端通过以下命令进行设置,Dash已经搜索不到Startup了: gnome-session-properties 或者直接在Dash中搜索:gnome-session

  9. Win7 系统管理员设置了系统策略_禁止进行此安装_怎么办

    系统管理员设置了系统策略,禁止进行此安装,怎么办 最佳答案 尝试方法一:   windows开始菜单,运行里面输入gpedit.msc打开组策略,   在"计算机配置"→管理模板→ ...

  10. [LeetCode][Java] 4Sum

    题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = ...