码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 2147

时间:2014-07-26 14:30:21      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   os   strong   

kiki‘s game

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


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
 
解题:利用P/N态,作图
bubuko.com,布布扣

P点:就是P个石子的时候,对方拿可以赢(自己输的)

N点:就是N个石子的时候,自己拿可以赢

现在关于P,N的求解有三个规则

(1):最终态都是P

(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P

(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N

 以上内容摘自http://blog.163.com/gditacmfeng@yeah/blog/static/13702062420100160358818/

 

bubuko.com,布布扣
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <climits>
 7 #include <vector>
 8 #include <queue>
 9 #include <cstdlib>
10 #include <string>
11 #include <set>
12 #define LL long long
13 #define INF 0x3f3f3f3f
14 using namespace std;
15 
16 int main(){
17     int n,m;
18     while(scanf("%d%d",&n,&m),n+m){
19         n %= 2;
20         m %= 2;
21         if(n && m) puts("What a pity!");
22         else puts("Wonderful!");
23     }
24     return 0;
25 }
View Code

 

hdu 2147,布布扣,bubuko.com

hdu 2147

标签:des   style   blog   http   java   color   os   strong   

原文地址:http://www.cnblogs.com/crackpotisback/p/3869816.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!