标签:
1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #define LL long long 5 6 LL gcd(LL a, LL b) 7 { 8 LL r = b; 9 while (r) 10 { 11 r = a % b; 12 a = b; 13 b = r; 14 } 15 return a; 16 } 17 18 LL lcm(LL a, LL b) 19 { 20 return a * b / gcd(a, b); 21 } 22 23 int main() 24 { 25 #ifdef CDZSC_OFFLINE 26 freopen("in.txt", "r", stdin); 27 freopen("out.txt", "w", stdout); 28 #endif 29 int t, n; 30 LL a, b; 31 scanf("%d", &t); 32 while (t--) 33 { 34 scanf("%d%lld", &n, &a); 35 while (--n) 36 { 37 scanf("%lld", &b); 38 a = lcm(a, b); 39 } 40 printf("%lld\n", a); 41 } 42 return 0; 43 }
标签:
原文地址:http://www.cnblogs.com/LiuACG/p/4246576.html