HDU 2147 kiki's game

來源:互聯網
上載者:User

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;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.