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. clock_gettime接口和linux时间系统

    RTC/OSCRTC,Real Time Clock,真实时钟,也叫做CMOS时钟,又叫walltimeOSC,Operation System Clock,系统时钟.在开机时操作系统取得RTC中的时 ...

  2. C/C++之static函数与普通函数

    全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量.全局变量本身就是静态存储方式, 静态全局变量当然也是静态存储方式.这两者在存储方式上并无不同.这两者的区别虽在于非静态全局变量 ...

  3. c++第五天:默认初始化

    1.算数类型.(整型和浮点型) 类型决定了数据所占的比特数以及该如何解释这些比特的内容. 练习2.1... 各种类型在计算机中所占的比特数不同,解释方法不同.有符号要花费一个比特存储符号,最大正值要比 ...

  4. YAML配置文件

    最近,研究jeeweb这个框架,发现新版本中的配置文件都是用的.yml为后缀的文件,打开一看,和以前的xml和properties语法有很大区别,因此仔细研究一下. 简介: YAML是(YAML Ai ...

  5. Observer模式实践

    Observer 模式在实践中的应用场景: 为 Point 类设计一个数据绑定机制,当其坐标 x 或 y 被更改时,可以通知外界其更改的过程.将更改过程打印在控制台上.考虑使用松耦合设计. 代码: # ...

  6. 基于Swoole和Redis实现的并发队列处理系统

    背景 由于PHP不支持多线程,但是作为一个完善的系统,有很多操作都是需要异步完成的.为了完成这些异步操作,我们做了一个基于Redis队列任务系统. 大家知道,一个消息队列处理系统主要分为两大部分:消费 ...

  7. 20145304 Exp3 免杀原理与实践

    20145304 Exp3 免杀原理与实践 基础问题回答 (1)杀软是如何检测出恶意代码的? 检验特征码,包含特征码的代码会被杀软认为是恶意代码,例如一些常用恶意代码加壳后就有一个固定的代码会被认为是 ...

  8. Duilib Edit编辑框禁止输入中文的方法

    转载:http://www.myexception.cn/vc-mfc/300749.html 编辑框是供用户输入的,但有时候我们要限制用户输入的内容,比如我们不让用户输入中文,只能输入字符和数字,因 ...

  9. 可持久化fhq-treap学习笔记

    目录 可持久化fhq-treap----- 支持查询历史版本的非旋treap 先看看为啥他可以可持久化 过程 别的 注意&&出错&&吐槽 模板->luoguP38 ...

  10. mysql链接 显示 error: 'Access denied for user 'root'@'localhost' (using password: NO)'

    解决方案 https://stackoverflow.com/questions/2995054/access-denied-for-user-rootlocalhost-using-password ...