多个数的最小公倍数 HDU1019
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 5 using namespace std; 6 7 int gcd(int a,int b) 8 { 9 if(b==0) 10 return a; 11 else 12 return gcd(b,a%b); 13 } 14 15 int main() 16 { 17 int t; 18 cin>>t; 19 while(t--) 20 { 21 int n; 22 cin>>n; 23 long long x; 24 int first=1; 25 long long ans; 26 for(int i=0;i<n;i++) 27 { 28 cin>>x; 29 if(first) 30 { 31 first=0; 32 ans=x; 33 } 34 else 35 { 36 ans=ans*x/gcd(ans,x); 37 } 38 } 39 cout<<ans<<endl; 40 } 41 return 0; 42 }