PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000130. ƯCLN hoặc giá trị nhỏ hơn (GCD or MIN)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
ƯCLN hoặc giá trị nhỏ hơn (GCD or MIN)
GCD or MIN
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A blackboard initially holds positive integers. Perform exactly operations: erase two present values and write back either or . Count the number of distinct possible final integers over all valid operation sequences.
Input
The first line contains ; the second contains the original values .
Output
Print the number of distinct possible last values.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
6 9 12
Output
2
Explanation
To obtain 3, replace (9,12) by gcd 3, then take min(6,3). To obtain 6, replace (6,12) by gcd 6, then take min(6,9). No other final values are possible.