CF1366D.Two Divisors
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n integers a1,a2,…,an.
For each ai find its two divisors d1>1 and d2>1 such that gcd(d1+d2,ai)=1 (where gcd(a,b) is the greatest common divisor of a and b) or say that there is no such pair.
给你 n 个整数 a1,a2,…,an。
对每个 ai,找出它的两个大于 1 的因数 d1>1 和 d2>1,使得 gcd(d1+d2,ai)=1(其中 gcd(a,b) 表示 a 与 b 的最大公约数);若不存在这样的数对,则说明不存在。
输入格式
The first line contains single integer n (1≤n≤5⋅105) — the size of the array a.
The second line contains n integers a1,a2,…,an (2≤ai≤107) — the array a.
第一行包含一个整数 n(1≤n≤5⋅105)——数组 a 的大小。
第二行包含 n 个整数 a1,a2,…,an(2≤ai≤107)——数组 a。
输出格式
To speed up the output, print two lines with n integers in each line.
The i-th integers in the first and second lines should be corresponding divisors d1>1 and d2>1 such that gcd(d1+d2,ai)=1 or −1 and −1 if there is no such pair. If there are multiple answers, print any of them.
为了加快输出速度,请输出两行,每行包含 n 个整数。
第一行和第二行的第 i 个整数应分别为满足 gcd(d1+d2,ai)=1 的对应因子 d1>1 和 d2>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=8. It has 3 divisors greater than 1: 2, 4, 8. As you can see, the sum of any pair of divisors is divisible by 2 as well as a7.
There are other valid pairs of d1 and d2 for a10=24, like (3,4) or (8,3). You can print any of them.
我们来看 a7=8。它有 3 个大于 1 的约数:2、4、8。如你所见,任意两个约数之和既能被 2 整除,也能被 a7 整除。
对于 a10=24,还存在其他满足条件的约数对 (d1,d2),例如 (3,4) 或 (8,3)。你可以输出其中任意一个。
输入解题思路,AI测评打分。不知道怎么写?