hdu_2147_kiki's game

kiki's game


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
 

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!
#include 
#include 
#include 
using namespace std;

//int win[2000][2000];打印PN表,找规律
/*
bool sg(int n, int m)
{
	if (win[n][m] != -1)
		return win[n][m];
	if (!sg(n - 1, m) || !sg(n - 1, m - 1) || !sg(n, m - 1))
	{
		win[n][m] = 1;
		return 1;
	}
	win[n][m] = 0;
	return 0;
}
*/
int main()
{
	int n, m;
	/*memset(win, -1, sizeof(win));
	for (int i = 1; i < 2000; i++)
	{
		if (i % 2 == 0)
		{
			win[i][1] = 1;
			win[1][i] = 1; 
		}
		else 
		{
			win[i][1] = 0;
			win[1][i] = 0;
		}
	}
	win[1][1] = 0;
	for (int i = 1; i < 100; i++)
	{
		for (int j = 1; j < 100; j++)
		{
			if (win[i][j] == -1)
				sg(i, j);
			printf("%d %d %d\n", i, j, win[i][j]);
			getchar();
		}
	}*/
	while (scanf("%d%d", &n, &m) != EOF && n +m)
	{
		if (n % 2 == 0 || m % 2 == 0)
			printf("Wonderful!\n");
		else 
			printf("What a pity!\n");
	}	
	return 0;
}


你可能感兴趣的:(博弈)