第四届全国中医药院校大学生程序设计竞赛
郑州, 2019 年 11 月 10 日
Problem C. Least Common Multiple
Input file: stdin
Output file: stdout
Memory limit: 256 megabytes
In arithmetic and number theory, the least common multiple of two integers a and b, usually denoted
by LCM (a, b), is the smallest positive integer that is divisible by both a and b.
The LCM of more than two integers is also well-defined: it is the smallest positive integer that is
divisible by each of them.
You are given n positive integers a
1
, a
2
, . . . , a
n
, please find the LCM of them.
Input
The first line of the input contains an integer T (1 ≤ T ≤ 10), denoting the number of test cases.
In each test case, there is one integer n(2 ≤ n ≤ 15) in the first line.
In the second line, there are n integers a
1
, a
2
, ..., a
n
(1 ≤ a
i
≤ 10
18
).
Output
For each test case, print a single line containing an integer, denoting the LCM. Since the answer can
be extremely large, please print it modulo 10
9
+ 7 instead.
Examples
stdin stdout
3
2
4 6
3
7 8 9
2
1000000009 1000000009
12
504
2
Page 3 of 15