本文主要是介绍HDU 2147 kiki's game 博弈,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我已经分不出来这是不是博弈了,反正我是没想到,看了别人的博客,我只想说给人类的智商跪了。。。。。。。。竟然是倒着推出来的
步骤1:将所有终结位置标记为必败点(P点);
步骤2: 将所有一步操作能进入必败点(P点)的位置标记为必胜点(N点)
步骤3:如果从某个点开始的所有一步操作都只能进入必胜点(N点) ,则将该点标记为必败点(P点) ;
步骤4: 如果在步骤3未能找到新的必败(P点),则算法终止;否则,返回到步骤2。
其实是这样的p只能到n,n跟p相连所以只要第一个人每次都到p第二个人就输定了。反过来也是这样,只要看看终点是不是和起点相同就行相同就输定了。。。
然后根据表格找规律。。
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?
Output
If kiki wins the game printf "Wonderful!", else "What a pity!".
Sample Output
What a pity!
Wonderful!
Wonderful!
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{int n,m;while(~scanf("%d %d",&n,&m)){if(n==0&&m==0)break;if(n%2!=0&&m%2!=0)printf("What a pity!\n");elseprintf("Wonderful!\n");}return 0;
}
这篇关于HDU 2147 kiki's game 博弈的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!