#K72497. Smallest Number Divisible by All Coins
Smallest Number Divisible by All Coins
Smallest Number Divisible by All Coins
You are given q queries. For each query, you are given an integer n which represents the number of coins, followed by n integers representing the coin values. For each query, you are to compute the smallest number that is divisible by all distinct coin values provided.
The smallest number divisible by a set of numbers is their least common multiple (LCM). The LCM for two numbers a and b is given by the formula:
\(\text{lcm}(a,b) = \frac{a \times b}{\gcd(a,b)}\)
If the coin list is empty (i.e. n = 0), output 1.
inputFormat
The input is read from standard input and has the following format:
q n1 c1 c2 ... cn1 n2 c1 c2 ... cn2 ... nq c1 c2 ... cnq
where q is the number of queries. For each query, the first line contains the integer n, the number of coins, followed by a line containing n space-separated integers representing the coin values.
outputFormat
For each query, print a single line to standard output that contains the smallest number that is divisible by all distinct coin values in that query.
## sample3
3
2 4 8
4
1 2 3 4
5
2 3 5 7 11
8
12
2310
</p>