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
月野兔
 
Source
 
Recommend
威士忌   |   We have carefully selected several similar problems for you:  1846 1847 1848 1849 1517 
 
 
 
显然(1,1)是必败态,因为没有操作可以选择
那么由必胜态的定义(一步之内能走到必败态的状态叫必胜态)(1,2),(2,2),(2,1)都是必胜态
依次类推可以打一个表出来(必败态:下一步无论怎样转移都会转移到必胜态)
找规律
n,m都是奇数的时候会输!
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. #include<cstring>
  5. #include<sstream>
  6. #include<algorithm>
  7. #include<queue>
  8. #include<deque>
  9. #include<iomanip>
  10. #include<vector>
  11. #include<cmath>
  12. #include<map>
  13. #include<stack>
  14. #include<set>
  15. #include<functional>
  16. #include<fstream>
  17. #include<memory>
  18. #include<list>
  19. #include<string>
  20. using namespace std;
  21. typedef long long LL;
  22. typedef unsigned long long ULL;
  23.  
  24. #define N 100
  25. #define MAXN 20000 + 9
  26. #define INF 1000000009
  27. #define eps 0.00000001
  28. #define sf(a) scanf("%d",&a)
  29.  
  30. int n;
  31. int a[N];
  32. int main()
  33. {
  34. while (sf(n), n)
  35. {
  36. int sum = ;
  37. for (int i = ; i < n; i++)
  38. sf(a[i]), sum ^= a[i];
  39. if (sum == )
  40. cout << << endl;
  41. else
  42. {
  43. int ans = ;
  44. for (int i = ; i < n; i++)
  45. {
  46. if ((sum^a[i]) < a[i])
  47. ans++;
  48. }
  49. cout << ans << endl;
  50. }
  51. }
  52. }

博弈论入门题 kiki's game的更多相关文章

  1. 洛谷P3150 pb的游戏(1)题解 博弈论入门

    题目链接:https://www.luogu.org/problem/P3150 这道题目是博弈论的入门题. 我们以 必胜态 和 必败态 来讲解这个问题. 首先,下面的图片演示了前8个数的必胜态和必败 ...

  2. hdu 3695:Computer Virus on Planet Pandora(AC自动机,入门题)

    Computer Virus on Planet Pandora Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 256000/1280 ...

  3. poj 2524:Ubiquitous Religions(并查集,入门题)

    Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23997   Accepted:  ...

  4. poj 3984:迷宫问题(广搜,入门题)

    迷宫问题 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7635   Accepted: 4474 Description ...

  5. hdu 1754:I Hate It(线段树,入门题,RMQ问题)

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  6. poj 3254 状压dp入门题

    1.poj 3254  Corn Fields    状态压缩dp入门题 2.总结:二进制实在巧妙,以前从来没想过可以这样用. 题意:n行m列,1表示肥沃,0表示贫瘠,把牛放在肥沃处,要求所有牛不能相 ...

  7. zstu.4194: 字符串匹配(kmp入门题&& 心得)

    4194: 字符串匹配 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 206  Solved: 78 Description 给你两个字符串A,B,请 ...

  8. hrbustoj 1073:病毒(并查集,入门题)

    病毒Time Limit: 1000 MS Memory Limit: 65536 KTotal Submit: 719(185 users) Total Accepted: 247(163 user ...

  9. hdu 1465:不容易系列之一(递推入门题)

    不容易系列之一 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Sub ...

随机推荐

  1. [书目20141009]《ReWork》

    ReWork1: ============= 引言篇INTRODUCTION开局篇FIRST 新的现实缷负篇TAKEDOWNS 忘了“现实世界” 哪来的从错误中学习 计划即瞎猜 何必壮大? 工作狂 受 ...

  2. 原创 SqlParameter 事务 批量数据插入

    不错,很好,以后防注入批量事务提交虽然麻烦点研究了几个小时,但不会是问题了 SqlCommand cmd; HelpSqlServer helps = new HelpSqlServer(); //定 ...

  3. (四)SpringIoc之Bean装配

    在pom.xml的依赖 <dependencies> <!--测试包--> <dependency> <groupId>junit</groupI ...

  4. 关于Android软键盘把布局顶上去的问题

    首先说下我的需求:布局最上面是一个bar,有左上角返回按钮和标题,bar下面是一个ScrollView,里面有各种TextView和EditText, 点击下面的EditText时,不希望软键盘把ba ...

  5. 搜索可用docker镜像

    简介:这一步的目标是学会使用docker search命令来检索可用镜像. 搜索可用的docker镜像 目标: 提示: 正确的命令: 搜索可用的docker镜像 使用docker最简单的方式莫过于从现 ...

  6. php高效率对一维数组进行去重

    $input = array("a" => "green", "red", "b" => "gre ...

  7. reStructuredText学习

    reStructuredText学习====================2015年4月1日 学习的最好方法就是尽快动手开始.不断迭代,不断完善. reStructuredText学习v0.1版本. ...

  8. 自己编辑Nuget拓展包,并发布Nuget服务器,提供下载使用

    1. 在NuGet官网上注册并获取API Key 到NuGet上注册一个新的账号,然后在My Account页面,获取一个API Key,如果没有则在API keys 页面创建一个就可以. 2. 下载 ...

  9. (function(){})() 立即执行函数

    (function(){})() 立即执行函数 (function(a){})(5) 带参的

  10. 正则表达式,匹配查找函数(preg_match_all)flags参数对比

    格式: int preg_match_all ( string pattern, string subject, array matches [, int flags] ) 参数 flags 选项有以 ...