/*
* 求n个数的最小公倍数
*/
import java.util.*;
public class ACM2028 {
// 最大公约数
static long gcd(long a, long b) {
long r = a % b;
while (r != 0) {
a = b;
b = r;
r = a % b;
}
return b;
}
// 最小公倍数
static long lcm(long a, long b) {
return a * b / gcd(a, b);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n = in.nextInt();
long result = 1;
for (long i = 0; i < n; i++) {
long num = in.nextLong();
result = lcm(result, num);
}
System.out.println(result);
}
}
}
acm2028
最新推荐文章于 2019-09-01 08:15:03 发布