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都是奇数的时候会输!
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<deque>
#include<iomanip>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<functional>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL; #define N 100
#define MAXN 20000 + 9
#define INF 1000000009
#define eps 0.00000001
#define sf(a) scanf("%d",&a) int n;
int a[N];
int main()
{
while (sf(n), n)
{
int sum = ;
for (int i = ; i < n; i++)
sf(a[i]), sum ^= a[i];
if (sum == )
cout << << endl;
else
{
int ans = ;
for (int i = ; i < n; i++)
{
if ((sum^a[i]) < a[i])
ans++;
}
cout << ans << endl;
}
}
}

博弈论入门题 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. chart.js图表 传值问题

    php:         $json['status'] = ture;                $json['list']=implode(',',$data);                ...

  2. SSM Note

    1.获取项目的绝对路径:${pageContext.request.contextPath } 2.销毁session:session.invalidate(); 3.控制器接收前端参数时,参数名要与 ...

  3. 分享div、text、Box Shadow(阴影)演示及代码的页面

    附图: 直接上链接:www.css88.com/tool/css3Preview/Box-Shadow.html

  4. qt5.5版本的creator构建套件自动检测为警告

    原创,转载请注明http://www.cnblogs.com/dachen408/p/7226188.html 原因,安装qt在E盘,winsdksetup也在E盘 的原因,卸载winsdksetup ...

  5. 关于Farseer.net轻量级ORM开源框架 V1.0 概念版本开发的消息

    V0.2版的开源距离今天(05年03月)已有近3年的时间.可以说这个版本已经有点落伍的感觉了,呵呵. V0.2版至今一直处于BUG的修复及一些细小功能的增加,所以版本号上一直没有变化. 其实在这1.2 ...

  6. servlet 生命周期 与 初始化

    一. 生命周期 Servlet 通过调用 init () 方法进行初始化. Servlet 调用 service() 方法来处理客户端的请求. Servlet 通过调用 destroy() 方法终止( ...

  7. Java泛型中的协变和逆变

    Java泛型中的协变和逆变 一般我们看Java泛型好像是不支持协变或逆变的,比如前面提到的List<Object>和List<String>之间是不可变的.但当我们在Java泛 ...

  8. spring-shiro 配置

    配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www ...

  9. Learning Discriminative and Transformation Covariant Local Feature Detectors实验环境搭建详细过程

    依赖项: Python 3.4.3 tensorflow>1.0.0, tqdm, cv2, exifread, skimage, glob 1.安装tensorflow:https://www ...

  10. gprc-java与golang分别实现服务端,客户端,跨语言通信(一.java实现)

    1.在pom中引入 <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty< ...