当前位置: 代码迷 >> 综合 >> LightOJ-1247 Matrix Game
  详细解决方案

LightOJ-1247 Matrix Game

热度:83   发布时间:2023-11-23 12:36:04.0

LightOJ-1247 Matrix Game

每一行n个的石头块的数量之和为一堆,共m堆, 转化成普通nim博弈, 亦或求解。


#include <bits/stdc++.h>using namespace std;const int MAXN = 100;int main () {int t, n, m, x;int kase = 0;cin >> t;while (t--) {cin >> m >> n;int p = 0;for (int j = 0; j < n; j++) {cin >> x;p += x;}int status = p;for (int i = 1; i < m; i++) {p = 0;for (int j = 0; j < n; j++) {cin >> x;p += x;}status ^= p;}cout << "Case " << ++kase << ": " << (status == 0 ? "Bob" : "Alice") << "\n";}return 0;
}
  相关解决方案