677. Maximize XOR
0
Easy
Given an array of N numbers, you need to select K elements from the array in order to maximize the XOR of all the chosen elements.
Input Format
The first line of input consists of two integers N and K, separated by a space.
The second line of input consists of N space-separated integers.
The second line of input consists of N space-separated integers.
Output Format
Print the maximum XOR.
Example
Input
5 3
1 2 3 4 5
Output
7
Constraints
1<=n<=20
1<=k<=n
1<= nums[i] <=10000
1<=k<=n
1<= nums[i] <=10000
Loading...
View Submissions
Console