标签:
Description
Input
Output
Sample Input
2 2 3 2 4 2
Sample Output
LOSE LOSE WIN#include <cstdio> #include <set> #include <cstring> using namespace std; int g[210][210]; int grundy(int W, int H) { if (g[W][H] != -1) return g[W][H]; set<int> s; for (int i = 2; i <= W / 2; i++) s.insert(grundy(i, H) ^ grundy(W - i, H)); for (int i = 2; i <= H / 2; i++) s.insert(grundy(W, i) ^ grundy(W, H - i)); int res = 0; while (s.count(res)) res++; return g[W][H] = res; } int main() { int W, H; memset(g, -1, sizeof(g)); while (scanf("%d%d", &W, &H) != EOF) { if (grundy(W, H)) puts("WIN"); else puts("LOSE"); } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/kl28978113/article/details/47206333