zoukankan      html  css  js  c++  java
  • 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!
    ");
            else
                printf("Wonderful!
    ");
        }
        
        fclose(stdin);
    }
  • 相关阅读:
    Death Race
    中国队吃中药了?
    (zt)让我们相亲相爱一百年不动摇
    Subversion & Arfa Karim Randhawa
    要是有时间的话……
    (zt)山王
    (zt)东方红
    Oracle 备份 与 恢复 概述
    Solaris 网络 配置
    RAID 磁盘阵列 详解
  • 原文地址:https://www.cnblogs.com/phaLQ/p/10147296.html
Copyright © 2011-2022 走看看