2 câu trả lời
đáp án:
var a:array[1..100000000] of longint;
k,i,n,d:longint;
function uc(x,y:longint):longint;
var r:longint;
begin
x:=abs(x);
y:=abs(y);
while y<>0 do
begin
r:=x mod y;
x:=y;
y:=r;
end;
uc:=x;
end;
begin
read(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
k:=uc(a[1],a[2]);
for i:=3 to n do
k:=uc(a[i],k);
write(k);
end.
var a:aray[1..10000000] of longint;
i,n,t,r:longint;
begin
r:=y mod x;
while r<>0 do
begin
r:=x mod y;
x:=y;
y:=r;
end;
ucln:=x;
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]);
for i:=3 to n do
t:=ucln(t,a[i]);
write(t);
end.