AtCoder Beginner Contest 117
D
XXOR
AtCoder
⌀ 1423
原题
← C→
翻译中…

Problem Statement

翻译中…

You are given $N$ non-negative integers $A_1, A_2, ..., A_N$ and another non-negative integer $K$.

翻译中…

For a integer $X$ between $0$ and $K$ (inclusive), let $f(X) = (X$ XOR $A_1)$ $+$ $(X$ XOR $A_2)$ $+$ $...$ $+$ $(X$ XOR $A_N)$.

翻译中…

Here, for non-negative integers $a$ and $b$, $a$ XOR $b$ denotes the bitwise exclusive OR of $a$ and $b$.

翻译中…

Find the maximum value of $f$.

翻译中…

What is XOR? The bitwise exclusive OR of $a$ and $b$, $X$, is defined as follows: When $X$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if, when written in base two, exactly one of $A$ and $B$ has $1$ in the $2^k$'s place, and $0$ otherwise. For example, $3$ XOR $5 = 6$. (When written in base two: $011$ XOR $101 = 110$.)

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \leq N \leq 10^5$
  • $0 \leq K \leq 10^{12}$
  • $0 \leq A_i \leq 10^{12}$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

Print the maximum value of $f$.

翻译中…

样例

Input #1
3 7
1 6 3
Output #1
14
The maximum value is: $f(4) = (4$ XOR $1) + (4$ XOR $6) + (4$ XOR $3) = 5 + 2 + 7 = 14$.
Input #2
4 9
7 4 0 3
Output #2
46
Input #3
1 0
1000000000000
Output #3
1000000000000
题目信息
题号
abc117_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。