Description
N numbers are given. Try to find the number with the largest quality factor.
Input Format: InputFormat
The first line is an integer N, indicating the number of digits.
In the next N rows, each row has an integer A_ I, indicating the given number.
Output Format: OutputFormat
An integer that represents the number with the largest prime factor.
Data range and comment Hint
N <= 5000, A_ I <= 20000
Example 38 and 12
38 = 19*2
12 = 2*3*3
The maximum value of 38 is 19.
The maximum value of 12 is 3.
Therefore, the data output is 38.
Sample input:
4
36
38
40
42
Sample output:
38
Code:
# Include
# Include
Int a [5010];
Int zhi (int n)
{
If (n = 2) return 1;
For (int I = 2; I <= sqrt (n); I ++)
If (n % I = 0) return 0;
Return 1;
}
Int yin (int n)
{
Int c;
If (zhi (n) return n;
For (int I = 2; I If (n % I = 0 & zhi (I) c = I;
Return c;
}
Int main (int argc, char * argv [])
{
Int n, I, max, l;
Scanf ("% d", & n );
For (I = 0; I Scanf ("% d", & a [I]);
Max = 1;
For (I = 0; I If (yin (a [I])> = max ){
Max = yin (a [I]); l = a [I];
}
Printf ("% d \ n", l );
Return 0;
}