cswork / OA打开练习工作台

MicrosoftOA #27

Get Max Or Sum

估计中等可在线判题

考点(AI 标注)位运算前缀和区间

Each operation picks one array element and multiplies it by 2, at most K times in total; maximize the bitwise OR of all elements. The resource-migration text at the start of the source has nothing to do with its explicit function and examples, so this site implements only the doubling rule.

输入格式

This site's ranges: the first line contains n K (1≤n≤100000, 0≤K≤30), and the second line contains n non-negative integers (0..10⁹).

输出格式

Output a single integer, the answer.

样例 1

输入:

2 1
12 9

输出:

30

样例 2

输入:

2 0
1 2

输出:

3

样例 3

输入:

2 3
0 0

输出:

0

样例说明

Example 1: doubling 9 gives 12 OR 18=30, which beats the 25 obtained by doubling 12.

Example 2: no operation is allowed, so the answer is 1 OR 2=3.

Example 3: doubling zero still gives zero, so the answer is 0.