题库练习 Bits
← 上一题 下一题 →

A9758 | Bits

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Let's denote as ![](/uploads/acgo/image/d63685b40032b5bd_2e83456f02b7.jpeg) 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 ![](/uploads/acgo/image/d63685b40032b5bd_2e83456f02b7.jpeg) is maximum possible. If there are multiple such numbers find the smallest of them.

输入格式

Let's denote as ![](/uploads/acgo/image/f3951b0e245b6956_77442afef145.jpeg) 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 ![](/uploads/acgo/image/f3951b0e245b6956_77442afef145.jpeg) is maximum possible. If there are multiple such numbers find the smallest of them.

输出格式

For each query print the answer in a separate line.

输入输出样例

输入 #1
3
1 2
2 4
1 10
输出 #1
1
3
7
C++ 编辑器
输入
输出