PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000126. Không thêm nữa (Not Adding)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Không thêm nữa (Not Adding)
Not Adding
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Initially, an array contains pairwise distinct positive integers. In one operation, choose elements at different indices and append their GCD to the array, provided that this GCD is not already present. Subsequent operations use the updated array. Determine the maximum possible number of operations.
Input
The first line contains ; the second contains pairwise distinct positive integers.
Output
Print the maximum number of append operations.
Subtasks
- Subtask 1 (20 points): ; và các đôi một khác nhau.
- Subtask 2 (30 points): ; và các đôi một khác nhau.
- Subtask 3 (50 points): ; và các đôi một khác nhau.
Examples
Input
5
4 20 1 25 30
Output
3
Explanation
Append 2 from gcd(4,30), 5 from gcd(20,25), and 10 from gcd(20,30). No other new value can be generated, so the answer is 3.