QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#5742. 垃圾处理

Statistics

你的国家有 $10^9$ 种垃圾和 $10^9$ 种垃圾桶。你只能将类型为 $x$ 的垃圾放入类型为 $y$ 的垃圾桶中,当且仅当 $\gcd(x, y) = 1$,其中 $\gcd(x, y)$ 表示整数 $x$ 和 $y$ 的最大公约数。

在你的社区中,只会产生类型在 $L \le x \le R$ 范围内的垃圾,且只有类型在 $L \le y \le R$ 范围内的垃圾桶可用。为了避免垃圾桶溢出,你希望将每一件垃圾投入不同的垃圾桶中。给定 $L$ 和 $R$,请找出一个合法的分配方案,或者报告该方案不存在。

输入格式

每个测试包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 10^5$)。

接下来是各测试用例的描述。 每个测试用例的第一行包含两个整数 $L$ 和 $R$ ($1 \le L \le R \le 10^9$)。

保证所有测试用例的 $R - L + 1$ 之和不超过 $10^5$。

输出格式

对于每个测试用例,如果不存在合法的分配方案,输出 $-1$。

否则,输出 $R - L + 1$ 个不同的整数 $y_L, y_{L+1}, \dots, y_R$ ($L \le y_i \le R$),使得对于每一个从 $L$ 到 $R$ 的 $i$,都有 $\gcd(y_i, i) = 1$。

如果存在多种解,输出任意一种即可。

样例

样例输入 1

3
1 5
10 13
100 100

样例输出 1

2 1 4 5 3
11 10 13 12
-1

说明

在第一个测试用例中,$\gcd(1, 1) = \gcd(2, 3) = \gcd(3, 4) = \gcd(4, 5) = \gcd(5, 2) = 1$。

在第二个测试用例中,$\gcd(10, 13) = \gcd(11, 10) = \gcd(12, 11) = \gcd(13, 12) = 1$。

在第三个测试用例中,唯一可能的分配是 $y_{100} = 100$,但 $\gcd(100, 100) = 100 \neq 1$。

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.