周赛一 HDU 2147 博弈论
来源:互联网 发布:上瘾网络剧见面会 编辑:程序博客网 时间:2024/04/29 14:14
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!
P点:就是P个石子的时候,对方拿可以赢(自己输的)
N点:就是N个石子的时候,自己拿可以赢
现在关于P,N的求解有三个规则
(1):最终态都是P
(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P
(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N
题意:
在一个m*n的棋盘内,从(1,m)点出发,每次可以进行的移动是:左移一,下移一,左下移一。然后kiki每次先走,判断kiki时候会赢(对方无路可走的时候)。
我们可以把PN状态的点描绘出来::
#include<iostream>#include<cstring>using namespace std;int main(){int n,m;while(cin>>n>>m){if(n==0&&m==0)break;if(n*m%2==0)cout<<"Wonderful!\n";elsecout<<"What a pity!\n";}}
0 0
- 周赛一 HDU 2147 博弈论
- 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 4664 Triangulation【博弈论】
- Hdu 1517 博弈论
- HDU 5011 Game(博弈论)
- HDU 3951 博弈论
- 博弈论-HDU-3951
- John - HDU 1907 博弈论
- HDU 4764 博弈论
- hdu-4764-博弈论
- hdu-4387-博弈论
- hdu 1847博弈论
- HDU 2147 kiki's game(巴什博弈论)
- Android四大组件之四:BroadcastReceiver 广播接收器
- MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(562,5): error MSB6006: “mt.exe”已退出,代码为 5
- Leetcode Exercise
- JAVA强制类型转换
- 诚信胜过生命
- 周赛一 HDU 2147 博弈论
- Jvm工作原理学习笔记
- BP神经网络模型与学习算法
- LIS 最长递增子序列 Java实现
- leetcode 93: Restore IP Addresses
- 宝宝杀
- OC学习 -- Property
- Arrays类、System类、Math类、时间日期类
- NSDate 日期,时间处理