原本以为是很简单的SG问题,一开始是打算利用动态规划的方法从后往前推,但是总是TLE。
后来把各个点的SG值打出来,发现了规律,这个规律我就不说了,你们自己慢慢推导一下
/*******************************************************************************
# Author : Neo Fung
# Email : neosfung@gmail.com
# Last modified: 2012-06-14 18:39
# Filename: HDU2147 kiki's game.cpp
# Description :
******************************************************************************/
#ifdef _MSC_VER
#define DEBUG
#define _CRT_SECURE_NO_DEPRECATE
#endif
#include <fstream>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <functional>
#include <ctype.h>
using namespace std;
const int kMAX=2010;
const double kEPS=10E-6;
int n,m;
// int g_sg[kMAX][kMAX];
int main(void)
{
#ifdef DEBUG
freopen("../stdin.txt","r",stdin);
freopen("../stdout.txt","w",stdout);
#endif
// for(int i=0;i<kMAX;++i)
// {
// if(i%2==0)
// g_sg[0][i]=g_sg[i][0]=0;
// else
// g_sg[0][i]=g_sg[i][0]=1;
// }
// for(int x=1;x<kMAX;++x)
// {
// for(int y=1;y<kMAX;++y)
// {
// bool visit[kMAX]={false};
// visit[g_sg[x-1][y-1]]=true;
// visit[g_sg[x-1][y]]=true;
// visit[g_sg[x][y-1]]=true;
// int cnt=0;
// while(visit[cnt])cnt++;
// g_sg[x][y]=cnt;
//
// }
// }
//
while(~scanf("%d%d",&n,&m) && (m+n))
{
--n;--m;
if(n%2 || m%2)
printf("Wonderful!\n");
else
printf("What a pity!\n");
}
return 0;
}