You have an array of n integers. But n integers is too much for
you, so you want to remove exactly k integers from them.
You should select these k integers in such a way that bitwise OR of the
remaining integers would be maximal possible.
It’s guaranteed that in any test either k ≤ 7, or all integers in the
array are not greater than 105.
Input
The first line contains integers n and k (0 ≤ k ≤ 100; k + 1 ≤
n ≤ 105). The second line describes the given array as a sequence of
n integers. All integers in the array are from 0 to 109.
Output
Output maximal possible value of bitwise OR of the remaining integers.
Samples
input | output |
---|
4 1
32 16 8 7
| 56
|
4 1
98765432 98765432 98765432 1
| 98765433
|
Notes
To calculate a bitwise OR of two integers you should write them in the
binary form and perform the OR operation for each pair of corresponding
bits. If both bits are 0, then this bit of result is 0, otherwise this bit
of result is 1.
Problem Author: Alexey Danilyuk
Problem Source: Ural FU Junior Championship 2016