kiki's game

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

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
 
  观察发现可以打表预处理一下整个棋盘,从左下角到右上角处理,每个位置只有1/0两种状态。当所有子状态全都是1的时候为0,否则为1.
 #include<bits/stdc++.h>
using namespace std;
bool f[][];
int fx[][]={,-,,,,-};
int main(){
int n,m,i,j,k;
n=;
m=;
f[n][]=;
for(i=n;i>=;--i){
for(j=;j<=m;++j){
if(i==n&&j==) continue;
int tot1=,tot2=;
for(k=;k<;++k){
int dx=i+fx[k][];
int dy=j+fx[k][];
/*if(i==5&&j==3)
cout<<dx<<" -"<<dy<<endl;*/
if(dx>=&&dx<=n&&dy>=&&dy<=m){
tot1++;
if(f[dx][dy]) tot2++;
}
} if(tot1==tot2) f[i][j]=;
else f[i][j]=;
}
}
while(cin>>n>>m&&(n&&m))
f[-n+][m]?puts("Wonderful!"):puts("What a pity!");
return ;
}

再仔细观察发现......

#include<stdio.h>
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)&&n&&m)
{
if(n%&&m%)
printf("What a pity!\n");
else
printf("Wonderful!\n");
}
return ;
}

hdu-2147-博弈的更多相关文章

  1. HDU 2147 (博弈) kiki's game

    无奈英语不好又被坑,看到棋子能左移下移左下移,想当然地以为是Wythoff博弈了,=u= 题的意思是说每次只能选一个方向移动一步,所以找找规律就是横纵坐标为奇数的时候是必败状态. 从http://ww ...

  2. HDU - 2147 博弈 P/N分析

    结论题,很显然和奇偶有关 PS.尝试用dfs写出PN表写崩了 #include<iostream> #include<algorithm> #include<cstdio ...

  3. hdu 2147 kiki&#39;s game, 入门基础博弈

    博弈的一些概念: 必败点(P点) : 前一个选手(Previous player)将取胜的位置称为必败点. 必胜点(N点) : 下一个选手(Next player)将取胜的位置称为必胜点. 必败(必胜 ...

  4. hdu 2147 kiki's game(巴什博弈)

    kiki's game HDU - 2147 题意:一个n*m的表格,起始位置为右上角,目标位置为左下角,甲先开始走,走的规则是可以向左,向下或者向左下(对顶的)走一格.谁先走到目标位置谁就胜利.在甲 ...

  5. HDU.2147 kiki's game (博弈论 PN分析)

    HDU.2147 kiki's game (博弈论 PN分析) 题意分析 简单的PN分析 博弈论快速入门 代码总览 #include <bits/stdc++.h> using names ...

  6. S-Nim HDU 1536 博弈 sg函数

    S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...

  7. HDU 2147 kiki's game(博弈经典题)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=2147 Problem Description Recently kiki has nothing to ...

  8. HDU 2147 kiki's game(规律,博弈)

    kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total ...

  9. (博弈 sg入门)kiki's game -- hdu -- 2147

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意: 在一个n*m的棋盘上,从  (1,m),即右上角开始向左下角走. 下棋者只能往左边(lef ...

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

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

随机推荐

  1. 【手把手教你树莓派3 (二)】 启动wifi模块

    概述 树莓派3内置了wifi和蓝牙模块,我们不用像以前的版本那样,再去购买一个外接的模块练到raspberry上. 当我们第一次启动了树莓派的时候,必然使用了网线,但是之后的每一次使用,我们当然更希望 ...

  2. P1283 平板涂色

    P1283 平板涂色 dfs 记忆化搜索 将矩阵转化为图求解,然后我们发现这是个DAG,于是就可以愉快地跑搜索了. 进行dfs时,我们可以用类似拓扑排序的方法.每次将上面所有矩形都被刷过(入度in[ ...

  3. 08: python基础练习题

    1.while循环实现输出2 - 3 + 4 - 5 + 6 ... + 100 的和 # 使用while循环实现输出2 - 3 + 4 - 5 + 6 ... + 100 的和 s = 0 i = ...

  4. Python3基础 list remove 删除元素

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  5. RSA加密解密中pkcs1与pkcs8格式私钥互相转换

    net,ios中rsa加解密使用的是pkcs1,而java使用的是pkcs8 如果是按1024取模(通常都是1024),pkcs1格式的私钥长度应该是812.如果是pkcs8的格式的密钥长度为861. ...

  6. JavaScript 小知识

    1.var 变量 <script type="text/javascript"> var a = "hong"; var fun = functio ...

  7. HDU 1796 How many integers can you find(容斥)题解

    思路:二进制解决容斥问题,就和昨天做的差不多.但是这里题目给的因子不是质因子,所以我们求多个因子相乘时要算最小公倍数.题目所给的因数为非负数,故可能有0,如果因子为0就要删除. 代码: #includ ...

  8. Java8的新特性,二进制序列转十进制数字

    package kata_007_二进制序列转十进制int; /** * java8 Lambda表达式转换binary序列->十进制数 */ import java.util.ArrayLis ...

  9. Unity3D学习笔记(二十五):文件操作

    文件是什么? 存储在硬盘上的最后的节点. 文件夹是什么? 文件的上级单位称为文件夹. 文件夹的基本结构? 文件夹是层级化结构的,对于同级的文件夹不可以重名,父文件夹和子文件夹可以同名> IO:I ...

  10. 01_re正则表达式

    正则表达式,是一个特殊的字符串, 是对一类字符串的描述 ( 怎么描述一类字符: 普通字符+元字符+重复)检测给定的字符串,是否和正则表达式描述的字符串相匹配 举例:1) 检查一串数字是否是电话号码2) ...