PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000099. Koxia và lý thuyết số (Koxia and Number Theory)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Koxia và lý thuyết số (Koxia and Number Theory)
Koxia and Number Theory
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of positive integers, determine whether there exists one common positive integer such that for every pair of distinct indices . You only need to decide existence, not output .
Input
The first line contains . The second line contains integers .
Output
Print YES if such an exists; otherwise print NO.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
5 7 10
Output
YES
Explanation
Choosing gives . Their pairwise GCDs are all , so the answer is YES.