天天看点

HDU 2147 kiki's game (巴什博弈) kiki‘s game

time limit: 5000/1000 ms (java/others)    memory limit: 40000/1000 k (java/others)

total submission(s): 5982    accepted submission(s): 3552

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

sample output

题意:一个n*m的表格,起始位置为右上角,目标位置为左下角,甲先开始走,走的规则是可以向左,向下或者向左下(对顶的)走一格。谁先走到目标位置谁就胜利。在甲乙都采用最佳策略的时候,先走者能否获胜。也是一个巴什博弈的题目。首先画出pn图,

HDU 2147 kiki's game (巴什博弈) kiki‘s game

如图就能很容易的看出,只要m或者n有一个是偶数先手就能必胜。