kiki's game

kiki‘s game

Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/1000 K (Java/Others)
Total Submission(s): 253 Accepted Submission(s): 41
 

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!


Author

月野兔


Source

HDU 2007-11 Programming Contest


Recommend

威士忌

/*
题意:就是一个n*m的棋盘,棋子在右上角(1,m),轮流走棋子,向左,向下,向左下,如果有人无法再走了,那么这个人就输了。

初步思路:递推,左下角是必败点,然后推,如果n*m是奇数那么先走的人一定输,反之则赢

#错误:直接判断奇偶会爆内存?!!要单独判断n m......单独判断还是炸
    看了原题,这个内存弄错了,这不是摆明了要用java么
*/
#include<stdio.h>
int main(){
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF&&(n+m)){
        if((n&1)&&(m&1)) printf("What a pity!\n");
        else printf("Wonderful!\n");
    }
}

java版的

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    // write your code here
        Scanner cin=new Scanner(System.in);
        int n,m;
        while(cin.hasNext()){
            n=cin.nextInt();
            m=cin.nextInt();
            if(n==0&&m==0) break;
            if(n%2==1&&m%2==1) System.out.println("What a pity!");
            else System.out.println("Wonderful!");
        }
    }
}

kiki's game

时间: 2024-10-24 07:44:12

kiki's game的相关文章

Hello Kiki(hdu3579+不互质的中国剩余定理)

Hello Kiki Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3579 Appoint description:  System Crawler  (2015-04-29) Description One day I was shopping in the supermarket. There was a cashier coun

HDU3579 Hello Kiki【一元线性同余方程组】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3579 题目大意: Kiki有X个硬币,她用不同的方式数了N次,每次她把硬币分成大小相等的组,记录每次一组硬币 的个数Mi和数完最后剩余的硬币数Ai.那么问题来了:总共有多少枚硬币? 思路: 典型的一元线性同余方程组X = Ai(mod Mi)求解.题目要求输出最小正整数解,则如果求得同余 方程组的解为0,那么答案就是所有Mi的最小公倍数. AC代码: #include<iostream> #in

HDU 1517: kiki&#39;s game

/** * @link http://acm.hdu.edu.cn/showproblem.php?pid=1517 * @author Sycamore * @date Aug, 21 */// Suppose that their exists a direction(vertically or horizontally) in which// the steps remaining to arrive at the destination (n-1 or m-1) is even, as

HDU——3579 Hello Kiki

Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4206    Accepted Submission(s): 1616 Problem Description One day I was shopping in the supermarket. There was a cashier counting coins

hdu2174 kiki&#39;s game 博弈

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

Hello Kiki(中国剩余定理——不互质的情况)

Hello Kiki Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 247 Accepted Submission(s): 107   Problem Description One day I was shopping in the supermarket. There was a cashier counting coins serio

HDU 2147 —— kiki&#39;s game

kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others) 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 th

【HDU】2147 kiki&#39;s game

http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意:n×m的棋盘,每次可以向左走.向下走.向左下走,初始在(1, m),n,m<=2000,问先手是否胜利. #include <cstdio> using namespace std; int main() { int n, m; while(scanf("%d%d", &n, &m), n|m) (n&1)&&(m&1)?

hdu 2147 kiki&#39;s game(DP(SG)打表找规律)

题意: n*m的棋盘,一枚硬币右上角,每人每次可将硬币移向三个方向之一(一格单位):左边,下边,左下边. 无法移动硬币的人负. 给出n和m,问,先手胜还是后手胜. 数据范围: n, m (0<n,m<=2000) 思路: dp[i][j]=0,说明从(i,j)这个点到时左下角先手败.dp[i][j]=1则先手胜. 然后记忆搜.但是记忆搜会超时. 搜完把整张表打出来,发现规律了,,,,然后,,,代码剩几行了. 代码: ///打表观察 /* int f[2005][2005]; int go(in