QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#14265. 未知图腾密码 (Easy)

Statistiques

请注意,这是题目 unowncode 的简单版本。

Unown Digits

在随意遗迹(Solaceon Ruins)中,山梨博士(Professor Rowan)一直在研究一群未知图腾(Unown),它们想出了一个密码。每个未知图腾的形状都像一个数字,它们组合在一起形成了 $N$ 个数字($a_1, \dots, a_N$)。它们的密码是最小的整数 $c > 1$,使得当每个数字 $a_i$ 被求 $c$ 次幂时,结果以 $a_i$ 结尾。例如,如果这些数字是 $3$ 和 $25$,那么密码将是 $5$,因为 $3^5 = 243$(以 $3$ 结尾),而 $25^5 = 9\,765\,625$(以 $25$ 结尾)。

编写一个程序来帮助山梨博士找出这个密码。

输入格式

输入的第一行包含一个整数 $N$($1 \le N \le 1\,000$),表示未知图腾组的数量。

第二行包含 $N$ 个空格分隔的整数 $a_1, \dots, a_N$($1 \le a_i \le 10\,000$),表示每组未知图腾所组成的数字。保证这些数字都不包含前导零。

输出格式

输出单行,包含该密码;如果不存在这样的密码,则输出 $-1$。

样例

输入样例 1

2
3 25

输出样例 1

5

输入样例 2

1
5

输出样例 2

2

输入样例 3

2
5 10

输出样例 3

-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.