DMOPC '21 Contest 4 P2 - Festive Groups

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

The N citizens of Dmojistan are arranging a Christmas gathering! The i-th citizen has a jolliness of Ji, and a group of citizens is festive if the smallest jolliness of a citizen in that group is a divisor of the jolliness of every citizen in the group. To ensure that the gathering is as exciting as possible, the N citizens want to split themselves into some number of groups, where each group is festive and the number of groups is minimized. Please determine the number of groups in such an arrangement.

Constraints

1N2×106

1Ji5×106

Subtask 1 [20%]

1N2×103

Subtask 2 [80%]

No additional constraints.

Input Specification

The first line contains an integer N.

The second line contains N integers J1,J2,,JN.

Output Specification

Output a single integer, the answer to the problem.

Sample Input

Copy
7
8 3 15 10 6 4 16

Sample Output

Copy
3

Explanation

The citizens may be divided into 3 festive groups as follows: [8,4,16],[3,15,6],[10].


Comments

There are no comments at the moment.