hdoj 2147 kiki's game【博弈】

kiki‘s game

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)
Total Submission(s): 8041    Accepted Submission(s):
4781

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!

查找必胜点和必败点

1、只能通向必胜点的是必败点

#include<stdio.h>
#include<string.h>
int main()
{
	int n,m,j,i;
	while(scanf("%d%d",&n,&m)&&n!=0&&m!=0)
	{
		if(n*m&1)
		printf("What a pity!\n");
		else
		printf("Wonderful!\n");
	}
	return 0;
}

  

hdoj 2147 kiki's game【博弈】

时间: 2024-10-12 19:06:23

hdoj 2147 kiki's game【博弈】的相关文章

HDU 2147 kiki&#39;s game(博弈图上找规律)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个方向移动,谁最后无法移动棋子就输掉比赛,问先手是否会获胜. 解题思路:简单题,P/N分析找规律,以(n,m)点为结束点推到起始点,如图: 发现每个田字格的状态都是一样的,因为(n,m)点一定时P态,所以可以得出规律:只有当(m%2==1&&n%2==1)时,先手才会输. 代码: 1 #incl

hdu 2147 kiki&#39;s game 博弈

点击打开链接链接 kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others) Total Submission(s): 6933    Accepted Submission(s): 4141 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears

【HDOJ 2147】 kiki&#39;s game

[HDOJ 2147] kiki's game 博弈题 可以找规律 也可以dp把所有情况标记出来 代码如下: #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <cmath> #de

HDU 2147 kiki&#39;s game(规律,博弈)

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 10763    Accepted Submission(s): 6526 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his

hdu 2147 kiki&#39;s game, 入门基础博弈

博弈的一些概念: 必败点(P点) : 前一个选手(Previous player)将取胜的位置称为必败点. 必胜点(N点) : 下一个选手(Next player)将取胜的位置称为必胜点. 必败(必胜)点属性 (1) 所有终结点是必败点(P点): (2) 从任何必胜点(N点)操作,至少有一种方法可以进入必败点(P点): (3)无论如何操作, 从必败点(P点)都只能进入必胜点(N点). hdu 2147 kiki's game 题意: 在一个m*n的棋盘内,从(1,m)点出发,每次可以进行的移动是

HDU 2147 kiki&#39;s game (巴什博弈)

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others) Total Submission(s): 5982    Accepted Submission(s): 3552 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his m

HDU 2147 kiki&#39;s game(巴什博弈论)

题目地址:HDU 2147 又是一道NP状态转换的巴什博弈.这题根据NP状态转移最好画个表格,规律就很直观了. 博弈么,从左下角往前推: P→到达该点后,下一个人必败. N→到达该点后,下一个人必胜. 显然,最左下角的点是P. 然后根据经过一步操作可到达必败状态的都是必胜状态,下一步操作都是必胜状态,那么这步操作时必败状态的原则一步步的去画表格就可以了.                                                                        

hdu2174 kiki&#39;s game 博弈

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

HDU 2147 —— kiki&#39;s game

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others) 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 th