HDU 2147 kiki's game 博弈论
程序员文章站
2022-06-09 17:56:08
...
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?
InputInput 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.
OutputIf kiki wins the game printf "Wonderful!", else "What a pity!".
Sample Input
Wonderful!
Wonderful!
传送门hdu崩着= =
套路似乎差不多……按照“全推N为P,能推P为N”的思路,这题左下角为P,然后可以扩展推导。本来可以O(NM)预处理的,但是空间比较小。。那么就找一找这个推导的规律。
X是必败态,O是必胜态;那么画一画就可以出来了。规律非常明显吧……
InputInput 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.
OutputIf kiki wins the game printf "Wonderful!", else "What a pity!".
Sample Input
5 3 5 4 6 6 0 0Sample OutputWhat a pity!
Wonderful!
Wonderful!
传送门hdu崩着= =
套路似乎差不多……按照“全推N为P,能推P为N”的思路,这题左下角为P,然后可以扩展推导。本来可以O(NM)预处理的,但是空间比较小。。那么就找一找这个推导的规律。
X是必败态,O是必胜态;那么画一画就可以出来了。规律非常明显吧……
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y;
while (1){
scanf("%d%d",&x,&y);
if (!x) break;
if (!(x&1)) puts("Wonderful!");
else
if (!(y&1)) puts("Wonderful!");
else puts("What a pity!");
}
return 0;
}
推荐阅读
-
博弈论入门 Bash 、Nim 、Wythoff's Game结论及c++代码实现
-
kiki's game (巴什博弈)
-
HDU-2147 kiki's game 巴什博弈
-
Euclid‘s Game HDU - 1525
-
HDU 2147 kiki's game 博弈论
-
基础博弈论之——简单的博弈问题【hdu1525】【Euclid‘s Game】
-
HDU 2147 kiki‘s game 博弈论 巴什博弈 PN图
-
HDU 1730 Northcott Game 博弈论 尼姆博弈
-
博弈论入门 Bash 、Nim 、Wythoff's Game结论及c++代码实现
-
2018HDU多校2-1004-Game(hdu 6312)-博弈论,思维