HDOJ_2147_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<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,1)谁就赢,所以谁先处于(奇,偶)或(偶,奇)或者(奇,奇)并此时给这个人下棋,这个人就赢了。
换句话说,只要现态不是(奇,奇)就是胜点,否则就是败点。
AC代码:
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    freopen("in.txt","r",stdin);
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF&&(n||m))
    {
        if(n%2==1&&m%2==1)
            printf("What a pity!\n");
        else
            printf("Wonderful!\n");
    }
    
    fclose(stdin);
}

 

posted @ 2018-12-20 06:09  pha创噬  阅读(137)  评论(0编辑  收藏  举报