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);
    }
  • 相关阅读:
    XML&nbsp; XmlDocument
    程序集报错
    程序打开网页
    写入文件txt
    读取文件txt
    MSM8953中Android系统添加启动脚本.rc文件
    SELinux基础知识
    嵌入式Linux设备查看USB相关信息
    Linux内核态文件读写相关函数API
    C语言中sscanf()函数相关用法
  • 原文地址:https://www.cnblogs.com/phaLQ/p/10147296.html
Copyright © 2011-2022 走看看