#GL0000335. Xóa ít phần tử nhất để mảng đẹp (Strange Beauty)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Xóa ít phần tử nhất để mảng đẹp (Strange Beauty)
Strange Beauty
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
An array of positive integers is called beautiful if, for every pair of different positions , their values are comparable by divisibility: either or .
You may delete any elements without changing the remaining values. Find the minimum number of deletions that makes the array beautiful. Equal values are always compatible, since any integer divides itself.
Each Phuoc Hung OJ input file contains one test case, not an initial test-count .
Input
The first line contains ; the second contains positive integers .
Output
Print the minimum number of elements to delete.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Example 1
Input
5
7 9 3 14 63
Output
2
Explanation
Remove and , leaving : these are comparable since . One deletion is insufficient.
Example 2
Input
3
2 14 42
Output
0
Explanation
The array is already beautiful because .
Example 3
Input
4
45 9 3 18
Output
1
Explanation
Removing leaves ; removing leaves . Either uses one deletion.
Example 4
Input
3
2 2 8
Output
0
Explanation
The equal elements are compatible and both divide , so no deletion is needed.
Note: Each input file contains one case using the specified format.