AcWing 891. Nim游戏

  

//a1 ^ a2 ^ ··· ^ an = 0 –>先手必败;
//a1 ^ a2 ^ ··· ^ an != 0 –>先手必胜;
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int res = 0;
    while(n --) {
        int x;
        cin >> x;
        res ^= x;
    }
    if (res) puts("Yes");
    else puts("No");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/QingyuYYYYY/p/11918940.html