题意:一个n*m的方格,有一个棋子初始在右上角(1,m),每次可以将棋子向下或者向左或者向左下移动一个格子,不能移出边界,当无路可走的时候就输了,问谁存在必赢策略。
思路:画n点p点。。。左下肯定是p 然后最后发现 n%2==1&&m%2==1的时候必输,否则必赢。
然后因为把m%2谢成名m&2 WA了好多发呵呵呵呵呵呵。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
/* *********************************************** Author :111qqz Created Time :2016年07月19日 星期二 20时09分37秒 File Name :code/hdu/2147.cpp ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <cstdlib> #include <ctime> #define fst first #define sec second #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define ms(a,x) memset(a,x,sizeof(a)) typedef long long LL; #define pi pair < int ,int > #define MP make_pair using namespace std; const double eps = 1E-8; const int dx4[4]={1,0,0,-1}; const int dy4[4]={0,-1,1,0}; const int inf = 0x3f3f3f3f; int n,m; int main() { #ifndef ONLINE_JUDGE freopen("code/in.txt","r",stdin); #endif while (scanf("%d%d",&n,&m)!=EOF) { if (n==0&&m==0) break; if (n%2==1&&m&2==1) { puts("What a pity!"); } else { puts("Wonderful!"); } } #ifndef ONLINE_JUDGE fclose(stdin); #endif return 0; } |
说点什么
您将是第一位评论人!