kiki's game
Posted 勿忘初心0924
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章