PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000114. Nhân một tập con (Subset Multiplication)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhân một tập con (Subset Multiplication)
Subset Multiplication
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Alice starts with an array of positive integers where divides for all . Bob chooses a positive integer and multiplies an arbitrary subset of positions (possibly empty or all positions) by to obtain the given array . Find any in for which a suitable original array and subset exist. A solution is guaranteed.
Input
The first line contains . The second line contains .
Output
Print a valid positive integer .
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
4
4 8 4 8
Output
4
Explanation
Starting from and multiplying the first two entries by produces .