You are given nn integers a1,a2,…,ana1,a2,…,an.
For each aiai find its two divisors d1>1d1>1 and d2>1d2>1 such that gcd(d1+d2,ai)=1gcd(d1+d2,ai)=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.
Input
The first line contains single integer nn (1≤n≤5⋅1051≤n≤5⋅105) — the size of the array aa.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (2≤ai≤1072≤ai≤107) — the array aa.
Output
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>1d1>1 and d2>1d2>1 such that gcd(d1+d2,ai)=1gcd(d1+d2,ai)=1 or −1−1 and −1−1 if there is no such pair. If there are multiple answers, print any of them.
有N个值(其实可以看成T组输入),然后求每一个a[i]能否被两个它的除数d1, d2给做到,然后这里用一下公式则有。(可以用反证法,假设存在,然后反证。)
然后我们可以找到第一个质因子为p,然后为了保证然后我们把a[i]的所有的p都给d1,然后剩下的就是d2了,只要d2不为1,那么就是有解了。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include