CF1366D.Two Divisors

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn integers a1,a2,…,ana_1, a_2, \dots, a_n.

For each aia_i find its two divisors d1>1d_1 \gt 1 and d2>1d_2 \gt 1 such that gcd⁡(d1+d2,ai)=1\gcd(d_1 + d_2, a_i) = 1 (where gcd⁡(a,b)\gcd(a, b) is the greatest common divisor of aa and bb) or say that there is no such pair.

给你 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n。

对每个 aia_i,找出它的两个大于 11 的因数 d1>1d_1 > 1 和 d2>1d_2 > 1,使得 gcd⁡(d1+d2,ai)=1\gcd(d_1 + d_2, a_i) = 1(其中 gcd⁡(a,b)\gcd(a, b) 表示 aa 与 bb 的最大公约数);若不存在这样的数对,则说明不存在。

输入格式

The first line contains single integer nn (1≤n≤5⋅1051 \le n \le 5 \cdot 10^5) — the size of the array aa.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (2≤ai≤1072 \le a_i \le 10^7) — the array aa.

第一行包含一个整数 nn(1≤n≤5⋅1051 \le n \le 5 \cdot 10^5)——数组 aa 的大小。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(2≤ai≤1072 \le a_i \le 10^7)——数组 aa。

输出格式

To speed up the output, print two lines with nn integers in each line.

The ii-th integers in the first and second lines should be corresponding divisors d1>1d_1 \gt 1 and d2>1d_2 \gt 1 such that gcd⁡(d1+d2,ai)=1\gcd(d_1 + d_2, a_i) = 1 or −1-1 and −1-1 if there is no such pair. If there are multiple answers, print any of them.

为了加快输出速度,请输出两行,每行包含 nn 个整数。

第一行和第二行的第 ii 个整数应分别为满足 gcd⁡(d1+d2,ai)=1\gcd(d_1 + d_2, a_i) = 1 的对应因子 d1>1d_1 \gt 1 和 d2>1d_2 \gt 1;若不存在这样的数对,则输出 −1-1。若存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    10
    2 3 4 5 6 7 8 9 10 24

    输出#1

    -1 -1 -1 -1 3 -1 -1 -1 2 2 
    -1 -1 -1 -1 2 -1 -1 -1 5 3

说明/提示

Let's look at a7=8a_7 = 8. It has 33 divisors greater than 11: 22, 44, 88. As you can see, the sum of any pair of divisors is divisible by 22 as well as a7a_7.

There are other valid pairs of d1d_1 and d2d_2 for a10=24a_{10}=24, like (3,4)(3, 4) or (8,3)(8, 3). You can print any of them.

我们来看 a7=8a_7 = 8。它有 33 个大于 11 的约数:22、44、88。如你所见,任意两个约数之和既能被 22 整除,也能被 a7a_7 整除。

对于 a10=24a_{10}=24,还存在其他满足条件的约数对 (d1,d2)(d_1, d_2),例如 (3,4)(3, 4) 或 (8,3)(8, 3)。你可以输出其中任意一个。

输入解题思路,AI测评打分。不知道怎么写?

首页