kiki's game
2014-8-7 10:15
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!
/*
此题的关键在于画出PN图就一切明朗了:
1 | 2 | 3 | 4 | 5 | 6 | 7 | |
1 | P | N | P | N | P | N | P |
2 | N | N | N | N | N | N | N |
3 | P | N | P | N | P | N | P |
4 | N | N | N | N | N | N | N |
5 | P | N | P | N | P | N | P |
6 | N | N | N | N | N | N | N |
7 | P | N | P | N | P | N | P |
所以对于n*m的棋盘,只有在n和m都是奇数的时候才会出现P,也即是说n和m均奇数的时候先走的必败
*/
#include<stdio.h>
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m),!(n==0&&m==0))
{
if((n&1)&&(m&1)) printf("What a pity!\n");
else printf("Wonderful!\n");
}
return 0;
}