1 条题解
-
0
#include <bits/stdc++.h> using namespace std; //-1 没做过,0:先手必败,1:先手必胜 int book[1005][1005]; bool dfs(int x, int y) { if (x < y) swap(x, y); // x >= y if (book[x][y] != -1) return book[x][y]; if (y == 0) return book[x][y] = false; if (x % y == 0) return book[x][y] = true; // 枚举从x里拿走多少 bool flag = true; //后续状态全都是先手必胜态 for (int i = y; i <= x; i += y) if (!dfs(x - i, y)) return book[x][y] = true; return book[x][y] = false; } int main() { memset(book, -1, sizeof(book)); int x, y; while (cin >> x >> y) { if (x == 0 && y == 0) break; if (dfs(x, y)) cout << "win\n"; else cout << "lose\n"; } return 0; }
- 1
信息
- ID
- 438
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 101
- 已通过
- 33
- 上传者