PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000095. Orac và BCNN (Orac and LCM)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Orac và BCNN (Orac and LCM)
Orac and LCM
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of positive integers , compute for every pair of indices . Collect these values into a multiset (including duplicates). Find the GCD of all values in .
Input
The first line contains . The second line contains positive integers .
Output
Print the GCD of the LCMs of all index pairs.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4
10 24 40 80
Output
40
Explanation
The six pairwise LCMs are . Their GCD is , so the answer is .