CF484A.Bits
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's denote as
the number of bits set ('1' bits) in the binary representation of the non-negative integer x.
You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and
is maximum possible. If there are multiple such numbers find the smallest of them.
我们用
表示非负整数 x 的二进制表示中置位(即值为 '1')的比特位个数。
你将收到多个查询,每个查询由一对整数 l 和 r 组成。对每个查询,请找出满足 l≤x≤r 且
尽可能大的整数 x。若存在多个满足条件的数,则输出其中最小的一个。
输入格式
The first line contains integer n — the number of queries (1 ≤ n ≤ 10000).
Each of the following n lines contain two integers l__i, r__i — the arguments for the corresponding query (0 ≤ l__i ≤ r__i ≤ 1018).
第一行包含一个整数 n — 查询的数量(1 ≤ n ≤ 10000)。
接下来的 n 行,每行包含两个整数 li、ri — 对应查询的参数(0 ≤ li ≤ ri ≤ 1018)。
输出格式
For each query print the answer in a separate line.
对于每个查询,在单独的一行中输出答案。
输入输出样例
输入#1
3 1 2 2 4 1 10
输出#1
1 3 7
说明/提示
The binary representations of numbers from 1 to 10 are listed below:
110 = 12
210 = 102
310 = 112
410 = 1002
510 = 1012
610 = 1102
710 = 1112
810 = 10002
910 = 10012
1010 = 10102
1 到 10 的数字的二进制表示如下所示:
110=12
210=102
310=112
410=1002
510=1012
610=1102
710=1112
810=10002
910=10012
1010=10102
输入解题思路,AI测评打分。不知道怎么写?