#C5307. Simultaneous Plant Bloom

    ID: 48942 Type: Default 1000ms 256MiB

Simultaneous Plant Bloom

Simultaneous Plant Bloom

You are given several test cases and for each test case, you need to determine the minimum number of days after which all types of plants bloom simultaneously.

For each test case, you are given an integer \(N\) representing the number of plant types, followed by \(N\) positive integers, each representing the growth cycle (in days) of a plant type. All plants of the same type bloom after multiples of their cycle days.

Your task is to compute the least common multiple (\(\text{lcm}\)) of these \(N\) cycle values. The answer for each test case is the minimum number of days after which all plants bloom together.

Recall that the least common multiple of two numbers \(a\) and \(b\) can be computed as:

\(\displaystyle \text{lcm}(a, b) = \frac{|a \times b|}{\gcd(a, b)}\)

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N1 a11 a12 ... a1N1
N2 a21 a22 ... a2N2
...
NT aT1 aT2 ... aTNT

Where:

  • T is an integer representing the number of test cases.
  • For each test case, the first integer is \(N\), the number of plant types.
  • The following \(N\) integers denote the cycle days for each plant type.

outputFormat

For each test case, output a single integer on a new line representing the minimum number of days after which the plants bloom simultaneously.

## sample
2
3 2 3 4
2 3 5
12

15

</p>