• 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);
    }
  • 相关阅读:
    正则表达式速查表
    Python第三方库管理Anaconda
    Python3.x和Python2.x的区别
    python 学习 “笨办法学python”(随书补充)
    python 中文输入的注意事项
    mongodb update 字符 操作(补充)
    mongodb update 字符 操作
    04.视频播放器通用架构实践
    05.视频播放器内核切换封装
    03.视频播放器Api说明
  • 原文地址:https://www.cnblogs.com/phaLQ/p/10147296.html
Copyright © 2020-2023  润新知