LightOJ-1186 Incredible Chess
nim博弈, 将两个棋子之间的距离看作是堆中的石子的数量, 然后就转化成一个简单的nim博弈。
#include <bits/stdc++.h>using namespace std;const int MAXN = 105;
int x[MAXN];int main () {int t, n, p;int kase = 0;cin >> t;while (t--) {cin >> n;for (int i = 0; i < n; i++) {cin >> x[i];}for (int i = 0; i < n; i++) {cin >> p;x[i] = p - x[i] - 1;}int status = x[0];for (int i = 1; i < n; i++) {status ^= x[i];}cout << "Case " << ++kase << ": " << (!status ? "black wins" : "white wins") << "\n";}return 0;
}