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!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int a[][];
  5. void init(void)
  6. {
  7. a[][] = ; //必败点
  8. for(int i = ; i < ; i++) //第一行与第一列
  9. {
  10. if(a[][i-])
  11. a[][i] = ; //一步能进入必败点标记为必胜点
  12. else
  13. a[][i] = ; //不能标记为必败点
  14.  
  15. if(a[i-][])
  16. a[i][] = ; //一步能进入必败点标记为必胜点
  17. else
  18. a[i][] = ; //不能标记为必败点
  19. }
  20. for(int i = ; i < ; i++) //中间的位置
  21. {
  22. for(int j = ; j < ; j++)
  23. {
  24. if(a[i][j-] || a[i-][j] || a[i-][j-])
  25. a[i][j] = ; //一步能进入必败点标记为必胜点
  26. else
  27. a[i][j] = ; //不能标记为必败点
  28. }
  29. }
  30. }
  31.  
  32. int main()
  33. {
  34. /*
  35. 画P/N图得出当n,m为奇数时kiki必败
  36. init();
  37. for(int i = 1; i < 50; i++)
  38. {
  39. for(int j = 1; j < 50; j++)
  40. {
  41. if(a[i][j])
  42. {
  43. cout << i%2 << " " << j%2 << endl;
  44. }
  45. }
  46. }
  47. */
  48. int n, m;
  49. while(cin >> n >> m && (n || m))
  50. {
  51. if(n% && m%)
  52. cout << "What a pity!" << endl;
  53. else
  54. cout << "Wonderful!" << endl;
  55. }
  56.  
  57. return ;
  58. }

HDU_2147——组合博弈,转换为P/N图,然后找规律的更多相关文章

  1. HDU 2147 kiki's game(博弈图上找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个 ...

  2. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  3. 2017EC Final L SOS——找规律&&博弈

    题意 有n个格子排成一行,两人轮流填,可填入"S"或"0",先得到"SOS"的人胜:如果全部填完也没有出现"SOS",则 ...

  4. 博弈论 | 详解搞定组合博弈问题的SG函数

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天这篇是算法与数据结构专题的第27篇文章,我们继续深入博弈论问题.今天我们要介绍博弈论当中非常重要的一个定理和函数,通过它我们可以解决许多 ...

  5. c语言实现灰度图转换为二值图

    将上篇得到的灰度图转换为二值图,读取像素数据,低于某一值置0,否则设置为255,为得到更好的效果不同图片应采用不同的值 /* 2015年6月2日11:16:22 灰度图转换为二值图 blog:http ...

  6. hdu_5724_Chess(组合博弈)

    题目链接:hdu_5724_Chess 题意: 给你一个n行20列的棋盘,棋盘里面有些棋子,每个棋子每次只能往右走一步,如果右边有棋子,可以跳过去,前提是最右边有格子,如果当前选手走到没有棋子可以走了 ...

  7. 题解报告:hdu 1564 Play a game(找规律博弈)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1564 Problem Description New Year is Coming! ailyanlu ...

  8. BZOJ-1228 E&D 博弈SG+找啊找啊找规律

    讨厌博弈,找规律找半天还是错的.... 1228: [SDOI2009]E&D Time Limit: 10 Sec Memory Limit: 162 MB Submit: 666 Solv ...

  9. 51nod_1831: 小C的游戏(Bash博弈 找规律)

    题目链接 此类博弈不需要考虑sg函数,只需要确定必胜态和必败态,解题思路一般为打败先打表找规律,而后找规律给出统一的公式.打表方式:给定初始条件(此题中为ok[0]=ok[1]=0),然后从低到高枚举 ...

随机推荐

  1. [转] Are You Making a Big Mistake in This Volatile Market?

    Stock market volatility continues unabated. It may be too early to tell, but I’m marking the top of ...

  2. 安装Stomp扩展时错误提示error: 'zend_class_entry' has no member named 'default_properties'

    在安装stomp扩展时, 有这样的提示 error: 'zend_class_entry' has no member named 'default_properties' 交待下安装上下文, sto ...

  3. POJ 1265 Area POJ 2954 Triangle Pick定理

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5227   Accepted: 2342 Description ...

  4. 解决第三方DLL没有强签名

    -----转载:http://blog.csdn.net/zyming0815/article/details/5939090 创建一个新的随机密钥对:sn -k myTest.snk 第一步: 将D ...

  5. (转)ThinkPHP Where 条件中使用表达式

    转之--http://www.cnblogs.com/martin1009/archive/2012/08/24/2653718.html Where 条件表达式格式为: $map['字段名'] = ...

  6. MySQL 序列使用

    MySQL 序列使用 MySQL序列是一组整数:1, 2, 3, ...,由于一张数据表只能有一个字段自增主键, 如果你想实现其他字段也实现自动增加,就可以使用MySQL序列来实现. 本章我们将介绍如 ...

  7. CSP内容安全策略

    在浏览网页的过程中,尤其是移动端的网页,经常看到有很多无关的广告,其实大部分广告都是所在的网络劫持了网站响应的内容,并在其中植入了广告代码.为了防止这种情况发生,我们可以使用CSP来快速的阻止这种广告 ...

  8. php 时间戳 总结 今日,昨日,上周,本周,最近三个月,上季,本季,去年,最近七天,今年,最近三十天

    if($time=="今日"){ $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); $endToday=mktime ...

  9. SVN 不能提交, 看不到日志, 出现乱码. 解决方案.

    需要工具 sprite3: 点这里下载. 解决问题 如本文标题所写. 我遇到过几次一样的问题, 每次都很蛋疼的把目录重新检出, 浪费时间, 又伤了脾气. 下面是我在百度经验找到的一片帖子, 效果杠杠的 ...

  10. C# 判断字符串是否可以转化为数字

    C# 判断字符串是否可以转化为数字 /// <SUMMARY> /// 判断字符串是否可以转化为数字 /// </SUMMARY> /// <PARAM name=&qu ...