CF1366D.Two Divisors

普及/提高-

通过率:0%

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 > 1 and d2>1d_2 > 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.

输入格式

The first line contains single integer nn ( 1n51051 \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 ( 2ai1072 \le a_i \le 10^7 ) — the array 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 > 1 and d2>1d_2 > 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.

输入输出样例

  • 输入#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.

首页