#P7696. [COCI 2009/2010 #4] IKS
[COCI 2009/2010 #4] IKS
Description
One day, she wrote down a sequence of numbers on a piece of paper, and told Mirko that he could perform the following operation any number of times:
- Choose two numbers in the sequence (let us call them ), then choose a prime number that divides . After that, Mirko erases and writes in its original position, and erases and writes in its original position.
Mirko wants to get the maximum score, because then he can get candies from his great-grandmother. The score of a sequence containing numbers is the greatest common divisor of these numbers.
Mirko is not good at this, but he really wants the candies, so he came to you. You should write a program to compute the maximum possible score, and also the minimum number of operations needed while still achieving this maximum score.
Input Format
The input consists of two lines.
The first line contains an integer , the number of elements in the sequence.
The second line contains integers, describing the sequence Katica gave to Mirko.
Output Format
Output one line with two integers. The first integer is the maximum score Mirko can obtain, and the second integer is the minimum number of operations needed to obtain the maximum score.
3
4 4 1
2 1
3
8 24 9
12 3
5
4 5 6 7 8
2 2
Hint
[Sample 1 Explanation]
For sample , Mirko can choose the two numbers and in the sequence, and choose the only prime factor of . Then Mirko erases and , and writes in both of their original positions. The score of this sequence is . It can be proven that this achieves the maximum possible score, and the number of operations is minimal under this condition.
[Constraints]
For all testdata, , and each element in the sequence is at most .
[Source]
This problem comes from COCI 2009-2010 CONTEST 4 T3 IKS. Using the original testdata settings, the full score is points.
Translated and organized by Eason_AC.
Translated by ChatGPT 5
京公网安备 11011102002149号