全部异或起来,如果不为零,则可以一步使其变为0:
设异或和为x,x的最高位为第k位,令第k位为1的a[i]变为a[i]^x,a[i]^x < a[i],这样就可以使异或和为0。
如此往复最终先手可以走到0^0^...^0
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;
int main()
{
IOS
int n, res = 0;
cin >> n;
for(int i = 0; i < n; i ++)
{
int x;
cin >> x;
res ^= x;
}
if(res)cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}