文章
61
粉丝
137
获赞
18
访问
42.6k
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
if(b == 0) return a;
else return gcd(b, a % b);
}
int lcm(int a, int b){
return a*b / gcd(a, b);
}
int main(){
int n;
int tmp1, tmp2;
while(cin >> n){
priority_queue<int, vector<int>, greater<int>> pq;
for(int i = 0; i < n; i++){
cin >> tmp1;
pq.push(tmp1);
}
while(pq.size() > 1){
tmp1 = pq.top();
pq.pop();
tmp2 = pq.top();
pq.pop();
tmp1 = lcm(tmp1, tmp2);
pq.push(tmp1);
}
cout << pq.top() << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发