PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000123. Tăng ƯCLN của dãy (Enlarge GCD)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tăng ƯCLN của dãy (Enlarge GCD)
Enlarge GCD
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , you may remove elements but must keep at least one. Find the minimum number of removals so that the GCD of all remaining values is strictly greater than the original array GCD. Print -1 if this is impossible.
Input
The first line contains ; the second contains integers .
Output
Print the minimum number of removals, or -1.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
1 2 4
Output
1
Explanation
The original GCD is 1. Removing the first element leaves 2 and 4, whose GCD is 2. One removal is minimal.