popcount ≥ KAI (CI翻译)
Problem Statement
You are given positive integers $N,C,K$.
Find the smallest positive integer $X$ satisfying $\displaystyle\min_{0\le i < N} \text{popcount}(X+Ci) \geq K$.
It can be proved that such a positive integer $X$ always exists.
You are given $T$ test cases; solve each of them.
What is popcount? For a non-negative integer $x$, $\operatorname{popcount}(x)$ is the number of $1$s in the binary representation of $x$. More formally, for a non-negative integer $x$ satisfying $\displaystyle x=\sum _ {i=0} ^ \infty b _ i2 ^ i\ (b _ i\in\lbrace0,1\rbrace)$, we have $\displaystyle\operatorname{popcount}(x)=\sum _ {i=0} ^ \infty b _ i$. For example, $13$ in binary is 1101, so we have $\operatorname{popcount}(13)=3$.
Constraints
$1\le T \le 10^5$$1\le N\le 10^8$$1\le C\le 30$$1\le K\le 30$- All input values are integers.
Input
The input is given from Standard Input in the following format:
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
Each test case is given in the following format:
N C K
Output
Output the answers for the test cases in order, separated by newlines.
{"titleZh":"popcount ≥ K","bodyZh":"## 题目描述\n\n给定正整数 $N,C,K$。\n\n请找出满足 $\displaystyle\\min_{0\\le i < N} \\text{popcount}(X+Ci) \\geq K$ 的最小正整数 $X$。\n\n可以证明,这样的正整数 $X$ 始终存在。\n\n给定 $T$ 组测试数据,请分别求出每组的答案。\n\n什么是 popcount?对于非负整数 $x$,$\operatorname{popcount}(x)$ 表示 $x$ 的二进制表示中 $1$ 的个数。更正式地,对于满足 $\displaystyle x=\\sum _ {i=0} ^ \\infty b _ i2 ^ i\\ (b _ i\\in\\lbrace0,1\\rbrace)$ 的非负整数 $x$,有 $\displaystyle\\operatorname{popcount}(x)=\\sum _ {i=0} ^ \\infty b _ i$。例如,$13$ 的二进制表示为 1101,因此 $\operatorname{popcount}(13)=3$。\n\n## 约束条件\n\n- $1\\le T \\le 10^5$\n- $1\\le N\\le 10^8$\n- $1\\le C\\le 30$\n- $1\\le K\\le 30$\n- 所有输入值均为整数。\n\n## 输入格式\n\n输入从标准输入按以下格式给出:\n\n\n\n## 输出格式\n\n按顺序输出各组测试数据的答案,每个答案占一行。"}AI (CI翻译)\nT\n\\text{case}_1\n\\text{case}_2\n\\vdots\n\\text{case}_T\n`\n\n每组测试数据按以下格式给出:\n\n`\nN C K\n
样例
3
3 1 3
6 7 12
100000000 30 30
13
32711
144115183780888607
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。