-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimum_XOR.cpp
More file actions
40 lines (39 loc) · 823 Bytes
/
minimum_XOR.cpp
File metadata and controls
40 lines (39 loc) · 823 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int a;
cin >> a;
int b[a];
cin >> b[0];
int minValue = b[0], small = 1000000;
for (int i = 1; i < a; i++)
{
cin >> b[i];
minValue = minValue ^ b[i];
}
small = minValue;
if (minValue == 0)
{
cout << minValue << endl;
continue;
}
else
{
for (int i = 0; i < a; i++)
{
int temp = minValue ^ b[i];
if (small > temp)
{
small = temp;
}
}
cout << small << endl;
}
}
return 0;
}