C語言源碼: [cpp] #include<stdio.h> #include<math.h> long long gcd(long long a,int b) { return b==0?a:gcd(b,a%b); } int main() { long long n,m,s,a,i; while(scanf("%lld",&n)!=EOF) { while(n--) { scanf("%lld",&m); for(i=0;i<m;i++) { scanf("%lld",&s); if(i==0) a=s; else a=a>s?(a*s/gcd(a,s)):(a*s/gcd(s,a)); } printf("%lld\n",a); } } }