PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000042. UCLN lớn nhất trong một dãy số (Maximum 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
UCLN lớn nhất trong một dãy số (Maximum GCD)
Maximum GCD
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers, consider every pair of distinct indices . Find the maximum value of . Equal values at different positions still form a valid pair.
Input
The first line contains ; the following line contains exactly positive integers.
Output
Print the maximum GCD over all pairs.
Subtasks
- Subtask 1 (20 points): ;
- Subtask 2 (30 points): ;
- Subtask 3 (50 points): ;
Examples
Input
4
12 15 18 24
Output
12
Explanation
The pair has GCD , which is not exceeded by any other pair.