2 câu trả lời
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;
function bc(x2,y2:longint):longint;
begin
bc:=x2 div uc(x2,y2)*y2;
end;
begin
read(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
k:=bc(a[1],a[2]);
for i:=3 to n do
k:=bc(a[i],k);
write(k);
end.
var A:ARRAY[1..1000000] of longint;
i,n,t:longint;
function ucln(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;
ucln:=x;
end;
begin
write('nhap n');
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('kq:',t);
readln;
readln;
end.
Câu hỏi trong lớp
Xem thêm