-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimum_XOR.cpp
More file actions
48 lines (41 loc) · 783 Bytes
/
Copy pathMinimum_XOR.cpp
File metadata and controls
48 lines (41 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int findXOR(const vector<long long> &arr)
{
long long result = 0;
for (long long num : arr)
{
result ^= num;
}
return result;
}
int main()
{
long long n;
cin >> n;
while (n--)
{
int t;
cin >> t;
vector<long long> a(t);
for (int i = 0; i < t; i++)
{
cin >> a[i];
}
long long l = a[0];
for (int i = 1; i < a.size(); i++)
{
l ^= a[i];
}
long long mini = l;
for (int i = 0; i < a.size(); i++)
{
long long n1 = l ^ a[i];
mini = min(mini, n1);
}
cout << mini << endl;
}
return 0;
}