异或
#数据结构#算法
异或有一个性质: a ^ b <= a + b,当两个数字分成两堆时不如分为一堆ans小
C++代码:
//a^b<=a+b
//code by homgzha
#include<bits/stdc++.h>
#define xx first
#define yy second
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n;cin >> n;
int ans=0, x;
while (n--) {
cin >> x;
ans ^= x;
}
cout << ans << endl;
return 0;
}