一、题目

二、题解:
b[i]=a[i]^x
, 并且b[1]^b[2]^b[3]^ b[4]^b[5]....=0


3、又因为^
满足结合律,因此,可以把括号给拆开

4、接着,因为x^x==0
,所以原式可以化简为:(题目中有提到x为奇数个)

5、因为0^x==x
,所以可以对等号两边同时求异或^

因此,我们可以发现所需要求的x
即是所有的a[i]
同时取异或
三、完整代码如下:
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
const int N = 2e5+7;
int a[N];void solve()
{int res = 0; int n; cin >> n;for (int i = 1; i <= n; i++) cin >> a[i];for (int i = 1; i <= n; i++){res ^= a[i];}cout << res << '\n';
}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int _ = 1; cin >> _;while (_--) solve();system("pause");return 0;
}