HDU 2147

题意略。

思路:

题中提到的3种操作,一个是将长方形的n减少1,一个是将m减少1,一个是将n和m同时减少1,都是将长方形规模减少的的操作。

现在我们可以知道,(1,1)先手必输;(1,2),(2,1),(2,2) 先手必胜。

所以先手如果足够聪明的话,就只要尽可能地让当前这两个维度为偶数,最终一定能达到上面3种必胜态;

后手如果足够聪明,就只要尽可能使两个维度为奇数,最终将对手逼到 (1,1)。

详见代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2005;

int main(){
    int n,m;
    while(scanf("%d%d",&n,&m) == 2 && (n + m)){
        printf("%s\n",!((n & 1) & (m & 1)) ? "Wonderful!" : "What a pity!");
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/tiberius/p/9364337.html
今日推荐