ユニークビジョンプログラミングコンテスト2022 冬(AtCoder Beginner Contest 283)
翻译中…
Problem Statement
翻译中…
Find the sum of popcounts of all integers between $1$ and $N$, inclusive, such that the remainder when divided by $M$ equals $R$.
Here, the popcount of a positive integer $X$ is the number of $1$s in the binary notation of $X$, that is, the number of non-negative integers $k$ such that the $2^k$s place is $1$.
For each input, process $T$ test cases.
翻译中…
Constraints
翻译中…
$1 \leq T \leq 10^5$$1 \leq M \leq N \leq 10^9$$0 \leq R < M$- All values in the input are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format. The first line is as follows:
翻译中…
T
翻译中…
$T$ test cases follow. Each of them is given in the following format:
翻译中…
N M R
翻译中…
Output
翻译中…
Print $T$ lines. The $i$-th line should contain the answer to the $i$-th test case.
翻译中…
样例
Input #1
2
12 5 1
6 1 0
Output #1
6
9
In the $1$-st test case, the popcount of $1$ is $1$, the popcount of $6$ is $2$, and the popcount of $11$ is $3$, so $1+2+3=6$ should be printed.
In the $2$-nd test case, the popcount of $1$ is $1$, $2$ is $1$, $3$ is $2$, $4$ is $1$, $5$ is $2$, and $6$ is $2$, so $1+1+2+1+2+2=9$ should be printed.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。