1 #include<iostream> 2 #include<iomanip> 3 //#include<bits/stdc++.h> 4 #include<cstdio> 5 #include<cmath> 6 #include<sstream> 7 #define PI 3.14159265358979 8 #define LL long long 9 #define eps 0.00000001 10 #define LL long long 11 using namespace std; 12 LL gcd(LL a,LL b) 13 { 14 if(a<b) swap(a,b); 15 LL r=a%b; 16 while(r) 17 { 18 a=b; 19 b=r; 20 r=a%b; 21 } 22 return b; 23 } 24 int main() 25 { 26 // freopen("input.txt","r",stdin); 27 LL T; 28 while(cin>>T) 29 { 30 LL a; 31 cin>>a; 32 LL temp=a; 33 for(LL i=2;i<=T;++i) 34 { 35 cin>>a; 36 temp=temp*a/gcd(temp,a); 37 } 38 cout<<temp<<endl; 39 40 } 41 }
原文:https://www.cnblogs.com/Auroras/p/10800688.html