#P1414. 又是毕业季II

    ID: 407 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>搜索数学递推洛谷原创最大公约数,gcd

又是毕业季II

Description

After one rehearsal, the teacher was not very satisfied. Of course, taking each student's ID number to compute a greatest common divisor is clearly unreasonable. So the teacher assigned an ability value to each student. Now the problem becomes: choose kk students from nn students so that their synergy (defined as the greatest common divisor of the selected ability values) is maximized. However, there are too many programs, and the required number of people for each program is unknown. The teacher wants to know, for every possible kk, the maximum achievable synergy. This is getting troublesome, so it is up to you.

Note: The greatest common divisor of a single number is the number itself.

Input Format

The first line contains a positive integer nn.

The second line contains nn space-separated positive integers, representing each student's ability value.

Output Format

Output nn lines. The ii-th line is the maximum synergy when k=ik = i.

4
1 2 3 4

4
2
1
1

Hint

Source: lzn original.

Constraints

Let the maximum ability value in the input be inf\textit{inf}.

  • For 20%20\% of the testdata, n5n \leq 5, inf103\textit{inf} \leq 10^3.
  • For another 30%30\% of the testdata, n100n \leq 100, inf10\textit{inf} \leq 10.
  • For 100%100\% of the testdata, n104n \leq 10^4, inf106\textit{inf} \leq 10^6.

Translated by ChatGPT 5