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
HDU 2007-11 Programming Contest
解题:利用P/N态,作图
P点:就是P个石子的时候,对方拿可以赢(自己输的)
N点:就是N个石子的时候,自己拿可以赢
现在关于P,N的求解有三个规则
(1):最终态都是P
(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P
(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N
以上内容摘自http://blog.163.com/[email protected]/blog/static/13702062420100160358818/
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 }
hdu 2147