QOJ.ac

QOJ

Limite de temps : 4.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#11311. GCD 之地

Statistiques

GCD Land 由 $N$ 座城市组成,初始编号为 $1$ 到 $N$。如果两座城市编号的 GCD(最大公约数)大于 $1$,则它们之间有一条公路相连。例如,初始时城市 $4$ 与城市 $6$ 相连,而城市 $4$ 与城市 $7$ 之间没有直接的公路。

作为 GCD Land 的总统,Panda 先生不希望他的国家被分割成互不连通的部分。该国睿智的首相 Ang 先生建议将每座城市的编号增加一个非负的魔法数字 $X$,使得在根据城市的新编号重新连接公路后,整个国家是连通的。例如,如果 Panda 先生将所有城市的编号增加 $8$,城市 $4$ 将同时与城市 $6$ 和城市 $7$ 相连,因为 $\gcd(12, 14) > 1$ 且 $\gcd(12, 15) > 1$。

你能帮助 Panda 先生找到这个魔法数字 $X$ 吗?要求 $X < 10^N$。如果不存在这样的 $X$,则输出 $-1$。

输入格式

输入的第一行包含测试用例的数量 $T$ ($1 \le T \le 20$)。接下来是 $T$ 个测试用例。每个测试用例包含一个整数 $N$ ($1 \le N \le 10^5$),表示 GCD Land 中的城市数量。对于至少 $75\%$ 的测试用例,保证 $N \le 5 \times 10^4$。

输出格式

对于每个测试用例,输出一行 “Case x: y”,其中 $x$ 是测试用例编号(从 $1$ 开始),$y$ 是存在的非负魔法数字,如果不存在则输出 $-1$。任何合法的解都会被接受。

样例

输入 1

2
6
30

输出 1

Case 1: -1
Case 2: 151060

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.