PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000167. Ước chung lớn nhất của một cặp (Common Divisors)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ước chung lớn nhất của một cặp (Common Divisors)
Common Divisors
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of positive integers , choose two distinct indices maximizing . Print the maximum GCD value, not the indices. Equal values at different indices are allowed.
Input
The first line contains . The second line contains positive integers .
Output
Print the largest possible GCD of two elements at distinct indices.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
5
3 14 15 7 9
Output
7
Explanation
The pair and yields . No other pair has a larger GCD.