0%

Problem 760


Problem 760


Sum over Bitwise Operators

Define
$$\displaystyle g(m,n) = (m\oplus n)+(m\vee n)+(m\wedge n)$$
where $\oplus, \vee, \wedge$ are the bitwise XOR, OR and AND operator respectively.

Also set
$$\displaystyle G(N) = \sum_{n=0}^N\sum_{k=0}^n g(k,n-k)$$

For example, $G(10) = 754$ and $G(10^2) = 583766$.

Find $G(10^{18})$. Give your answer modulo $1\ 000\ 000\ 007$.


位运算求和


$$\displaystyle g(m,n) = (m\oplus n)+(m\vee n)+(m\wedge n)$$
其中$\oplus, \vee, \wedge$分别代表“按位异或”、“按位或”和“按位与”运算。

再记
$$\displaystyle G(N) = \sum_{n=0}^N\sum_{k=0}^n g(k,n-k)$$

例如,$G(10) = 754$,$G(10^2) = 583766$。

求$G(10^{18})$,并将你的答案对$1\ 000\ 000\ 007$取余。