1 câu trả lời
var a:array[1..1000000] of longint;
i,n,t,r,k:longint;
function ucln(x,y:longint):longint;
begin
x:=abs(x);
y:=abs(y);
while y<>0 do
begin
r:=x mod y;
x:=y;
y:=r;
end;
ucln:=x;
end;
function bcnn(a,b:longint):longint;
begin
bcnn:=a div ucln(a,b)*b;
end;
begin
read(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do
t:=ucln(a[1],a[2]);
k:=bcnn(a[1],a[2]);
for i:=3 to n do
t:=ucln(t,a[i]);
k:=bcnn(k,a[i]);
write(t,' ');
write(k);
end.