kiki's game

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)
Total Submission(s): 10208    Accepted Submission(s): 6161

Problem Description
Recently kiki has nothing to do. While she is bored, an idea appears
in his mind, she just playes the checkerboard game.The size of the
chesserboard is n*m.First of all, a coin is placed in the top right
corner(1,m). Each time one people can move the coin into the left, the
underneath or the left-underneath blank space.The person who can't make a
move will lose the game. kiki plays it with ZZ.The game always starts
with kiki. If both play perfectly, who will win the game?
 
Input
Input
contains multiple test cases. Each line contains two integer n, m
(0<n,m<=2000). The input is terminated when n=0 and m=0.

 
Output
If kiki wins the game printf "Wonderful!", else "What a pity!".
 
Sample Input
5 3
5 4
6 6
0 0
 
Sample Output
What a pity!
Wonderful!
Wonderful!
 
Author
月野兔
题意:
n*m的方格,两个人游戏,起点是左上角,终点是右下角,谁先走到右下角谁赢,kiki总是先走,问谁赢。
思路:
找找规律

P点:就是P个石子的时候,对方拿可以赢(自己输的)

N点:就是N个石子的时候,自己拿可以赢

现在关于P,N的求解有三个规则

(1):最终态都是P

(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P

(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N

题意:

在一个m*n的棋盘内,从(1,m)点出发,每次可以进行的移动是:左移一,下移一,左下移一。然后kiki每次先走,判断kiki时候会赢(对方无路可走的时候)。

我们可以把PN状态的点描绘出来::                 可见都是奇数时是必败点。

 
 
都是
 
 

*HDU2147 博弈的更多相关文章

  1. 19-格子游戏(hdu2147博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=2147 kiki's game Time Limit: 5000/1000 MS (Java/Others)    ...

  2. hdu2147 kiki&#39;s game(博弈)

    这个是纳什博弈?不知道怎么看的 依据PN图,从左下角開始推 左下角P 最后一行都是PNPNPN 第一列都是 P N P N P 完了填完即可了 #include<cstdio> int m ...

  3. HDU2147 - kiki's game 【巴什博弈】

    Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes th ...

  4. ACM_小游戏(棋盘博弈)

    Problem Description: 最近kiki无事可做,于是他想玩棋盘游戏.棋盘的大小是n * m.首先,棋子放置在右上角(1,m). 每次可以将棋子向左方,下方或左下方移动一个位置.当移动到 ...

  5. hdu----(1849)Rabbit and Grass(简单的尼姆博弈)

    Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. HDU 5754 Life Winner Bo 组合博弈

    Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard gam ...

  7. HDU 2509 Nim博弈变形

    1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结 ...

  8. HDU 1907 Nim博弈变形

    1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形. ...

  9. 51nod1072(wythoff 博弈)

    题目链接: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1072 题意: 中文题诶~ 思路: 博弈套路是有的, 找np局 ...

随机推荐

  1. Android源码阅读 – Zygote

    @Dlive 本文档: 使用的Android源码版本为:Android-4.4.3_r1 kitkat (源码下载: http://source.android.com/source/index.ht ...

  2. Java基础回顾

    学习基础背景:Acmer.有C/C++基础 以[Java语言程序设计(基础篇)]第10版为参考(感谢YJJ的推荐),列出部分知识点,注意思考背后的原因和好处坏处. [14-16章——关于可视化编程的章 ...

  3. Best code水题之路

    BestCoder 2nd Anniversary: 1001.Oracle There is once a king and queen, rulers of an unnamed city, wh ...

  4. Java笔记:异常

    Exception 类的层次 所有的异常类是从 java.lang.Exception 类继承的子类. Exception 类是 Throwable 类的子类.除了Exception类外,Throwa ...

  5. [Android Pro] AsyncTaskLoader vs AsyncTask

    reference to : http://blog.csdn.net/a910626/article/details/45599133 我看了一下asyncTask是从LV3开始,AsyncTask ...

  6. Oracl中sql书写技巧

    1.写脚本(1)为什么不直接设置回滚点?因为服务器上数据库是很多人使用的,所以除了自己操作外,有很多人操作.如果设置回滚点时,回滚后,很多人操作都消失了,因此savepoint不可以.但是可以自己书写 ...

  7. Vi命令备忘

    备忘 Ctrl+u:向文件首翻半屏: Ctrl+d:向文件尾翻半屏: Ctrl+f:向文件尾翻一屏: Ctrl+b:向文件首翻一屏: Esc:从编辑模式切换到命令模式: ZZ:命令模式下保存当前文件所 ...

  8. Android中自定义控件TextSize属性问题

    本文主要说明一个自定义控件添加TextSize属性的坑,刚刚从坑里面爬出来,写个随笔,记录一下: *************************************************** ...

  9. Unity4、Unity5移动平台多线程渲染在部分安卓手机上会造成闪退

    你看到的crash堆栈可能是这样的: SIGSEGV(SEGV_MAPERR)   #00  pc 0001276c                          /system/lib/libc ...

  10. UVA 12300 Smallest Regular Polygon(正多边形)

    题意:给出两点,求经过这两点的正n边形的最小面积 题解:这两点一定是最长的弦,我们设正多边形中点c,找到c到每个点的距离(都相同) 我们知道那个等腰三角形的底与每个角度就使用余弦定理 #include ...