LightOJ-1192 Left Right

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37753409/article/details/82757945

LightOJ-1192 Left Right

nim博弈, 将灰色和白色棋子之间的距离看作是石头的数量, 可以转化成简单的nim博弈, 直接以后求解。

#include <bits/stdc++.h>

using namespace std;


int main () {
    int t, n, kase = 0;
    int x1, x2;
    cin >> t;
    while (t--) {
        cin >> n;
        cin >> x1 >> x2;
        int status = x2 - x1 - 1;
        for (int i = 1; i < n; i++) {
            cin >> x1 >> x2;
            status ^= (x2 - x1 - 1);
        }
        cout << "Case " << ++kase << ": " << (status == 0 ? "Bob" : "Alice") << "\n";  }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37753409/article/details/82757945
今日推荐