版权声明:欢迎神犇指教 https://blog.csdn.net/sdxtcqs/article/details/82221466
http://acm.hdu.edu.cn/showproblem.php?pid=2147
题意:给一个
的棋盘,棋子一开始位于右上角
处,两个人轮流移动棋子,只能向左,向下,向左下移动一格,不能再进行移动的人输,双方都采取最优策略,问谁赢。
找规律嘛,画出
图就很明显,
是偶数的时候,先手必胜。
图如下:
… | N | P | N | P | N | P |
---|---|---|---|---|---|---|
N | P | N | P | N | N | |
N | P | N | P | P | P | |
N | P | N | N | N | N | |
N | P | P | P | P | P | |
… | … |
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
int n,m,p;
while(1)
{
scanf("%d%d",&n,&m);
if(n==0&&m==0) break;
if(n%2==0||m%2==0) printf("Wonderful!\n");
else printf("What a pity!\n");
}
return 0;
}