#P9473. Product of Numbers equals LCM × GCD?
Product of Numbers equals LCM × GCD?
Product of Numbers equals LCM × GCD?
Given \(n\) positive integers \(a_1, a_2, \dots, a_n\), let \(g\) be the greatest common divisor (GCD) of these numbers and \(l\) be the least common multiple (LCM) of these numbers. You are required to determine whether \(l \times g = a_1 \times a_2 \times \cdots \times a_n\).
Note: For two numbers, it is a well-known fact that \(\mathrm{LCM}(a, b) \times \mathrm{GCD}(a, b) = a \times b\). However, this relationship does not generally extend to three or more numbers. Your task is to implement the check for any given \(n\) positive integers.
inputFormat
The first line contains a single integer \(n\) (the number of integers). The second line contains \(n\) positive integers \(a_1, a_2, \dots, a_n\) separated by spaces.
outputFormat
Output a single line: Yes
if \(l \times g = a_1 \times a_2 \times \cdots \times a_n\); otherwise, output No
.
sample
2
5 7
Yes