CF1366D.Two Divisors
普及/提高-
通过率:0%
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.
输入格式
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 .
输出格式
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.
输入输出样例
输入#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.