AT_arc220_e.popcount ≥ K
NOI/NOI+/CTSC
通过率:0%
时间限制:6.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given positive integers N,C,K.
Find the smallest positive integer X satisfying 0≤i<Nminpopcount(X+Ci)≥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, popcount(x) is the number of 1s in the binary representation of x. More formally, for a non-negative integer x satisfying x=i=0∑∞bi2i (bi∈{0,1}), we have popcount(x)=i=0∑∞bi.
For example, 13 in binary is 1101, so we have popcount(13)=3.
给定正整数 N,C,K。
求满足 0≤i<Nminpopcount(X+Ci)≥K 的最小正整数 X。
可以证明,这样的正整数 X 总是存在的。
你将得到 T 组测试数据;请对每组数据求解。
什么是 popcount?
对于非负整数 x,popcount(x) 表示 x 的二进制表示中 1 的个数。更形式化地,若非负整数 x 满足 x=i=0∑∞bi2i (bi∈{0,1}),则定义 popcount(x)=i=0∑∞bi。
例如,13 的二进制表示为 1101,因此 popcount(13)=3。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N C K
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N C K
输出格式
Output the answers for the test cases in order, separated by newlines.
按顺序输出测试用例的答案,答案之间用换行符分隔。
输入输出样例
输入#1
3 3 1 3 6 7 12 100000000 30 30
输出#1
13 32711 144115183780888607
说明/提示
Sample 1 Explanation:
Consider the first test case.
X=13 satisfies the condition, as confirmed below:
- When i=0: popcount(X+Ci)=popcount(13)=3
- When i=1: popcount(X+Ci)=popcount(14)=3
- When i=2: popcount(X+Ci)=popcount(15)=4
There is no positive integer smaller than 13 satisfying the condition, so output 13 on the first line.
Constraints
- 1≤T≤105
- 1≤N≤108
- 1≤C≤30
- 1≤K≤30
- All input values are integers.
样例 1 解释:
考虑第一个测试用例。
X=13 满足条件,验证如下:
- 当 i=0 时:popcount(X+Ci)=popcount(13)=3
- 当 i=1 时:popcount(X+Ci)=popcount(14)=3
- 当 i=2 时:popcount(X+Ci)=popcount(15)=4
不存在比 13 更小的正整数满足该条件,因此第一行输出 13。
约束条件
- 1≤T≤105
- 1≤N≤108
- 1≤C≤30
- 1≤K≤30
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?