#P9821. Bitwise AND and Logarithmic Double Sum
Bitwise AND and Logarithmic Double Sum
Bitwise AND and Logarithmic Double Sum
Given two non-negative integers X and Y, calculate the value of
$$ S = \sum_{i=0}^{X}\sum_{j=[i=0]}^{Y} [i\&j=0] \left\lfloor \log_2(i+j)+1 \right\rfloor \pmod{10^9+7} $$
where:
\&
denotes the bitwise AND operation.[A]
equals 1 if A is true, and equals 0 otherwise. In particular, the inner summation index j starts at[i=0]
which is 1 when i equals 0 and 0 otherwise.- \( \lfloor x \rfloor \) denotes the floor of x, i.e. the greatest integer less than or equal to x.
For each valid pair (i, j) (with i
from 0 to X and j
from [i=0]
to Y), if the condition i \& j = 0
holds then add \(\left\lfloor \log_2(i+j)+1 \right\rfloor\)
to the sum. Finally, output the result modulo \(10^9+7\).
inputFormat
The input consists of two non-negative integers X and Y separated by a space.
outputFormat
Output a single integer, the value of the defined sum modulo \(10^9+7\).
sample
0 1
1