Public Judge

pjudge

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#21686. 【NOIP Round #2】恰钱

Statistics

设 $\text{ctz}(x)$ 为 $x$ 二进制下末尾 $0$ 的个数,如 $\text{ctz}(1001000_2)=3$ 。

设 $\text{ppc}(x)$ 为 $x$ 二进制下 $1$ 的个数,如 $\text{ppc}(1001000_2)=2$ 。

定义一个数是好数,当且仅当 $\text{ctz}(x)=\text{ppc}(x)$ 。

给定 $Q$ ,有 $Q$ 次询问,每次给出区间 $[l,r]$ ,你需要求出 $[l,r]$ 中任意一个好数,或判断无解。

输入格式

第一行,一个正整数 $Q$ 。

接下来 $Q$ 行,每行两个正整数 $l,r$ 。

输出格式

每个询问输出一行,如果区间 $[l,r]$ 中存在好数,那么输出任意一个好数,否则输出 $-1$ 。

样例一

input

5
38 47
57 86
23 24
72 83
32 33

output

-1
68
-1
-1
-1

样例二、三

见下发文件。

数据范围与提示

本题采用子任务捆绑测试。

对于所有数据,保证 $1\le Q\le 10^5, 1\le l\le r\le 10^9$ 。

子任务编号 特殊性质 分值
$1$ $1\le l\le r\le 10^7$ $24$
$2$ $l,r$ 在 $[1,10^9]$ 中随机 $34$
$3$ $42$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.