提交时间:2024-05-25 15:53:25

运行 ID: 149071

#include<iostream> #include<cstdio> using namespace std; int Gcd(int a,int b){ if (b==0){ return a; }else{ Gcd(b,a%b); } } int main(){ int a,b,c,j; cin>>a; int k[a]; for(int i=1;i<=a;i++){ cin>>k[i]; } int d; c=k[1]; int g=k[1]; for(int i=2;i<=a;i++){ c=Gcd(c,k[i]); g=g*k[i]/c; } cout<<c<<" "<<g; }