#P12147. Sum of XOR Transformations

    ID: 14247 Type: Default 1000ms 256MiB

Sum of XOR Transformations

Sum of XOR Transformations

We define a function \( f(x) = x \oplus (x + 2^k) \), where \( \oplus \) denotes the bitwise exclusive OR operation. Given two integers \( n \) and \( k \), compute the value of

[ S = f(0) + f(1) + f(2) + \cdots + f(n)]

You can refer to the OI Wiki on Bitwise Operations for additional information.

inputFormat

The input consists of a single line containing two integers \( n \) and \( k \) separated by a space.

\( 0 \le n \le 10^5 \) (for instance) and \( 0 \le k \le 30 \). (Note: Constraints are given for example; adjust accordingly.)

outputFormat

Output a single integer representing the sum \( f(0)+ f(1)+ \cdots + f(n) \).

sample

3 2
16