hdu 1019(gcd & lcm)
1949 ワード
// ,gcd & lcm
//
#include <cstdio>
#include <iostream>
int gcd(int a, int b) {
return b ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
return a / gcd(a, b) * b;
}
int main() {
int t;
scanf ("%d", &t);
while (t--) {
int n, a, b, i;
scanf ("%d%d", &n, &b);
a = 1;
a = lcm(a, b);
for (i=1; i<n; ++i) {
scanf ("%d", &b);
a = lcm(a, b);
}
printf ("%d
", a);
}
return 0;
}