提交时间:2024-05-25 19:20:35
运行 ID: 149233
#include <bits/stdc++.h> using namespace std; unsigned long long gcd(unsigned long long m,unsigned long long n){ return n==0?m:gcd(n,m%n); } int main(){ unsigned long long n,a[100]; cin>>n; for(int i=0; i<n; i++) cin>>a[i]; unsigned long long 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<<endl; return 0; }