0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 16:58:48 +00:00

B3941 [GESP样题 五级] 小杨的锻炼

https://www.luogu.com.cn/record/174741177
This commit is contained in:
Baoshuo Ren 2024-08-25 22:59:56 +08:00
parent 8106ea66f5
commit 501093ba1b
Failed to extract signature

39
Luogu/B3941/B3941.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 15;
int n, a[N], ans;
int gcd(int x, int y) {
if (x == 0) return y;
return gcd(y % x, x);
}
int lcm(int x, int y) {
return x / gcd(x, y) * y;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ans = a[0];
for (int i = 1; i < n; i++) {
ans = lcm(ans, a[i]);
}
cout << ans << endl;
return 0;
}