题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1019
心得:
n个数的最小公倍数,两两求即可。
代码:
#include <iostream>
using namespace std;
int gcd(int a,int b){
if(!b) return a;
else return gcd(b,a%b);
}
int main(){
int N,n,x,y;
cin>>N;
while(N--){
cin>>n;
cin>>x;
n--;
while(n--){
cin>>y;
x=x/gcd(x,y)*y;
}
cout<<x<<endl;
}
}