提交时间:2024-08-21 16:34:21

运行 ID: 180616

#include <bits/stdc++.h> using namespace std; int gcd(int m, int n){ return n == 0 ? m : gcd(n, m % n); } int main(){ int n, a[100]; cin >> n; for(int i = 0; i < n; i++) cin>>a[i]; int ans1 = a[0], ans2 = a[0]; for(int i = 1; i < n; i++){ ans1 = gcd(ans1, a[i]); ans2 = ans2 / gcd(ans2, a[i]) * a[i]; } cout << ans1 << ' ' << ans2; return 0; }