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?
InputInput 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.OutputIf kiki wins the game printf "Wonderful!", else "What a pity!".Sample Input5 35 46 60 0Sample OutputWhat a pity!Wonderful!Wonderful!Author月野兔Source HDU 2007-11 Programming Contest Recommend威士忌 | We have carefully selected several similar problems for you: 1850 1847 1848 1849 1517
取決於這個棋盤的奇偶性,說白了。只要n,m中有一個為 偶數就可獲勝。
#include<iostream>#include<cmath>using namespace std;int m;int n;int main(){ while (cin >> n >> m&&m + n) { if (n % 2 == 0 || m % 2 == 0) { cout << "Wonderful!" << endl; } else { cout << "What a pity!" << endl; } } return 0;}