测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9758. Bits

编程题 普及/提高-

题目描述

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

说明/提示

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