Public Judge

pjudge

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

#21686. 【NOIP Round #2】恰钱

الإحصائيات

设 $\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$

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.