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. http协议/获得请求/中文参数处理/访问数据库

    # 1. http协议(了解)## (1)什么是http协议?一种网络应用层协议,规定了浏览器与web服务器之间如何通信以及相应的的数据包的结构.注:tcp/ip协议:保证数据可靠的传递.(UDP不可 ...

  2. poj 2777 Count Color - 线段树 - 位运算优化

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 42472   Accepted: 12850 Description Cho ...

  3. 在Windows下搭建Android开发环境及遇到的问题

    转载1:http://www.cnblogs.com/xdp-gacl/p/4322165.html 转载2:http://www.cnblogs.com/zoupeiyang/p/4034517.h ...

  4. POJ1061 青蛙的约会(扩展欧几里得)题解

    Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘记了一件很重要的事 ...

  5. Stream API

    引例: 1 List<String> strList = Arrays.asList("zhaojigang","nana","tiany ...

  6. [AtCoder ARC061F]Card Game for Three 组合数好题

    题目链接 总结:组合数 这$F$题好难啊...只会部分分做法,下面两个方法都是部分分做法.满分做法我去看看...会的话就补一下 部分分做法 方法1: 首先$A$能赢的条件很明显,假设在所有的牌里面取出 ...

  7. 总结java中的super和this关键字

    知识点: 在java类中使用super引用父类的成分,用this引用当前对象 this可以修饰属性.构造器.方法 super可以修饰属性.构造器.方法 关于子类实例化过程中的内存分配,在下一篇博客中说 ...

  8. jquery.cookie.js中$.cookie() 使用方法

    定义:让网站服务器把少量数据储存到客户端的硬盘或内存,从客户端的硬盘读取数据的一种技术: 下载与引入:jquery.cookie.js基于jquery:先引入jquery,再引入:jquery.coo ...

  9. C++小结:迟到的小结和重新起航的故事

    迟到的小结和重新起航的故事 有关这个学期的故事,随着这个学期的结束也划上了一个句号. 正如之前博客里面(还是空间里面)提到的,在这个过程中的收获比最后考试的结果更重要. 就像这次的计算器,也许会对最后 ...

  10. basename、dirname、alias、date

    basename 此命令用于打印目录或者文件的基本名称. basename和dirname命令通常用于shell脚本中的命令替换来指定和指定的输入文件名称有所差异的输出文件名称. basename ( ...