The Factor Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 1827 Accepted Submission (s): 551
Problem Description There is a sequence of n positive integers. Fancycoder is addicted to learn their product, but the this product could be extremely huge! However, it's lucky that fancycoder only needs to find out one factor of this huge product:the smallest factor that cont Ains more than 2 factors (including itself; i.e. 4 have 3 factors so, it is a qualified factor). You need to find it out and print it. As we know, there may be none of the such factors; In this occasion, please print-1 instead.
Input The first line contains one integer T (1≤t≤15), which represents the number of testcases.
For each testcase, there is and both lines:
1. The first line contains one integer denoting the value of N (1≤n≤100).
2. The second line contains n integers a1,..., an (1≤a1,..., an≤2x109), which denote these n positive integers.
Output Print T Answers in t lines.
Sample Input
2 3 1 2 3 5 6 6 6 6 6
Sample Output
6 4
Source bestcoder Round #54 (Div.2)
The product of a minimum of two mass factors can be
<span style= "font-family:arial, Helvetica, Sans-serif;" > #include <iostream></span> #include <cstdio>
#include <map>
using namespace std;
#define LL long
ll inf = 100000000007LL;
int main () {
int t,n;
scanf ("%d", &t);
while (t--) {
scanf ("%d", &n);
ll u;
ll X1=inf,x2=inf;
for (int j = 0;j < N; j + +) {
scanf ("%lld", &u);
for (ll i = 2;i * i <= u; i++) {while
(u% i = = 0) {
if (i < x1) x2 = x1, x1 = i;
else if (i < x2) x2 = i;
u/= i;
}
}
if (U = 1) {
if (U < x1) x2 = x1, x1 = u;
else if (U < x2) x2 = u;
}
}
if (x2 = = inf) printf (" -1\n");
else printf ("%lld\n", x1*x2);
}
return 0;
}