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. java 十三周总结

  2. codeforces round #394 (div. 2) A\B 题解

    开始啦~ 始まった T1 #include <stdio.h> int l,r,even,odd; void Jud(){ for(int i=1;i<=200;i++){ for( ...

  3. Ural 1091 Tmutarakan Exams

    Tmutarakan Exams Time Limit: 1000ms Memory Limit: 16384KB This problem will be judged on Ural. Origi ...

  4. hdu 2604 矩阵快速幂模板题

    /* 矩阵快速幂: 第n个人如果是m,有f(n-1)种合法结果 第n个人如果是f,对于第n-1和n-2个人有四种ff,fm,mf,mm其中合法的只有fm和mm 对于ffm第n-3个人只能是m那么有f( ...

  5. 阿里maven仓库配置

    修改conf文件夹下的settings.xml文件,添加如下镜像配置: <mirrors> <mirror> <id>alimaven</id> < ...

  6. git巧妙命令行

    git cherry-pick c7081607cfd1bfa99b6e6c70c208e71fbd8767ae

  7. Android Studio Module 的添加与删除

    1. 添加Module(此时可以字面翻译为“模块”,意译为“其他工程”) 2. 删除Module 你要知道,Android Studio的非人性设计,导致删除一个module都是繁琐的. 当你想在An ...

  8. Android:Unable to resolve target ‘android-8’问题解决

    在学习过程中,下载别人写过的代码,导入到eclipse,报错: Unable to resolve target 'android-8' 问题是项目版本号问题. 解决方法例如以下: 右击项目:Prop ...

  9. JAVA 并发编程-线程池(七)

    线程池的作用: 线程池作用就是限制系统中运行线程的数量. 依据系统的环境情况.能够自己主动或手动设置线程数量,达到运行的最佳效果:少了浪费了系统资源,多了造成系统拥挤效率不高.用线程池控制线程数量,其 ...

  10. 20170623_oracle_SQL

    ============SQL分类 数据定义语言(DDL):CREATE ALERT DROP TRUNCATE 数据操纵语言(DML):INSERT UPDATE DELETE SELECT 事务控 ...