Yet another challenge for Roy!
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
Both Hridoy and Roy enjoy solving mathematical puzzles as well as they are very close friends. They like challenging one another constantly, in keeping with this pattern, Hirdoy gave Roy a bitwise XOR problem which is very interesting for the bit lover. Hridoy set an array of N integers (\(A_1\), \(A_2\),... +\(A_N\)) together with an integer value (K). Roy was allowed to select a number X within this range which is 0 ≤ X ≤ K, By Choosing this X, Roy had to determine the maximum value of F(X) = (\(A_1\) ⊕ X) + (\(A_2\) ⊕ X) +... + (\(A_N\) ⊕ X).
Roy is asking for your assistance in fixing this problem since he is finding it tough to do so because of his busy schedule.
NOTE: ⊕ means XOR where XOR is a bitwise operator, and it stands for "exclusive or." It performs logical operation. If input bits are the same, then the output will be false(0) else true(1)
Input
The first line contains two integers N (3 ≤ N ≤ \(10^5\)) and K (1 ≤ K ≤ \(10^{12}\))
The second line contais N integers \(A_1\) , \(A_2\) ,,, \(A_N\) (1 ≤ \(A_N\) ≤ \(10 ^ {12}\))
Output
Print the maximum Value of F
Sample
Input | Output |
---|---|
|
|
Information
- ID
- 1054
- Difficulty
- 8
- Category
- DP Click to Show
- Tags
- (None)
- # Submissions
- 38
- Accepted
- 6
- Accepted Ratio
- 16%
- Uploaded By
Related
In following contests: