HDU 2147-kiki's game(NP图解决博弈论)
来源:互联网 发布:技术推算法 编辑:程序博客网 时间:2024/06/05 16:00
kiki's game
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uAppoint description:
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 35 46 60 0
Sample Output
What a pity!Wonderful!Wonderful!
题意:在一个m*n的棋盘内,从(1,m)点出发,每次可以进行的移动是:左移一,下移一,左下移一。然后kiki每次先走,判断kiki什么时候会赢(对方无路可走的时候)。
思路:sad,还是太水了,推了好长时间,这两天就认识了个尼姆博弈和巴什博奕,想往上面靠一靠,没成功,最后看了一下题解,用了NP图解决。
简单说一下NP图
P点:就是P个石子的时候,对方拿可以赢(自己输的)
N点:就是N个石子的时候,自己拿可以赢
现在关于P,N的求解有三个规则
(1):最终态都是P
(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P
(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N
我们可以把PN状态的点描绘出来:
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>using namespace std;int main(){ int n,m; while(~scanf("%d %d",&n,&m)){ if(!n&&!m) break; int a=n%2; int b=m%2; if(a&&b) printf("What a pity!\n"); else printf("Wonderful!\n"); } return 0;}
0 0
- HDU 2147-kiki's game(NP图解决博弈论)
- HDU 2147kiki's game 博弈论
- HDU 2147 kiki's game(博弈论)
- hdu 2147 kiki's game(博弈论)
- kiki's game - HDU 2147 博弈论
- hdu-2147-kiki's game-博弈论-java
- HDU 2147 kiki's game 博弈论
- HDU 2147 kiki's game(巴什博弈论)
- HDU.2147 kiki's game (博弈论 PN分析)
- hdu2147 kiki's game (博弈论问题 NP打表)
- hdu2147 -- kiki's game(博弈论)
- hdu 2147 kiki's game
- HDU-2147:kiki's game
- hdu 2147 kiki's game
- HDU 2147 - kiki's game
- hdu 2147 kiki's game
- HDU 2147 kiki's game
- HDU 2147kiki's game
- hdu1068 二分图的最大独立集
- grub rescue
- Scala-3 - 5 - Lecture 2.5 - Functions and Data (11_50)
- 进程与线程间的通信方式
- Codeforces 487C. Prefix Product Sequence 逆元+构造
- HDU 2147-kiki's game(NP图解决博弈论)
- c++之运算符重载
- proe二次开发的第一个程序
- RESTful 接口规范
- sicily 1419(动态规划)
- Java程序员从笨鸟到菜鸟之(十一)多线程讲解
- VS2013 Error LNK2011简易解决方案
- golang导包
- C++Primer 笔记之----变量和函数