AT_abc476_g.Increasing Popcount
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given positive integers L and R satisfying L≤R.
A sequence of positive integers A=(AL,AL+1,…,AR) of length R−L+1 satisfying the following condition is called a good integer sequence:
- For every pair of integers (i,j) satisfying L≤i<j≤R, if Ai=Aj, then popcount(i)<popcount(j).
Find the minimum value of max(AL,AL+1,…,AR) over all good integer sequences A=(AL,AL+1,…,AR).
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 1's when x is written in binary. More precisely, when a non-negative integer x satisfies x=i=0∑∞bi2i (bi∈{0,1}), popcount(x)=i=0∑∞bi.
For example, 13 written in binary is 1101, so popcount(13)=3.
给定满足 L≤R 的正整数 L 和 R。
长度为 R−L+1 的正整数序列 A=(AL,AL+1,…,AR),若满足如下条件,则称为好整数序列:
- 对于所有满足 L≤i<j≤R 的整数对 (i,j),若 Ai=Aj,则必有 popcount(i)<popcount(j)。
求所有好整数序列 A=(AL,AL+1,…,AR) 中 max(AL,AL+1,…,AR) 的最小可能值。
共给出 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.
L R
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
L R
输出格式
Output T lines.
The i-th line (1≤i≤T) should contain the answer for the i-th test case casei.
输出 T 行。
第 i 行(1≤i≤T)应包含第 i 个测试用例 casei 的答案。
输入输出样例
输入#1
5 3 6 1 1 2 15 100 10000000 514284786278117031 620546740167642909
输出#1
3 1 6 1636985 11375123021856567
说明/提示
Sample 1 Explanation:
Consider the first test case.
(A3,A4,A5,A6)=(1,2,2,3) is a good integer sequence, and max(A3,A4,A5,A6)=3.
There is no good integer sequence with max(A3,A4,A5,A6)<3, so output 3 on the first line.
Constraints
- 1≤T≤104
- 1≤L≤R≤1018
- All input values are integers.
样例 1 解释:
考虑第一个测试用例。
(A3,A4,A5,A6)=(1,2,2,3) 是一个“好”的整数序列,且 max(A3,A4,A5,A6)=3。
不存在满足 max(A3,A4,A5,A6)<3 的“好”整数序列,因此第一行输出 3。
约束条件
- 1≤T≤104
- 1≤L≤R≤1018
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?