题目链接:https://www.luogu.com.cn/problem/P1469
这一题用到了数学里面的异或运算,
异或运算的一个结论:
对一个数,k次异或, 如果k是奇数,则异或结果为它本身。如果k是偶数,则异或结果为0
所以这题,咱就直接异或吧。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int res;
int main(){
cin >> n;
while (n -- ){
int x; scanf("%d", &x);
res ^= x;
}
cout << res << endl;
return 0;
}