Cod sursa(job #147832)
Utilizator | Data | 3 martie 2008 17:12:11 | |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.62 kb |
var fi,fo:text;
T,i,a,b,c,d,x,y:longint;
procedure euclid(a,b:longint; var d,x,y:longint);
var x0,y0:longint;
begin
if b=0 then
begin
d:=a;
x:=1;
y:=0;
end
else
begin
euclid(b,a mod b,d,x0,y0);
x:=y0;
y:=x0-(a div b)*y0;
end;
end;
begin
assign(fi,'euclid3.in'); reset(fi);
assign(fo,'euclid3.out'); rewrite(fo);
read(fi,t);
for i:=1 to t do
begin
read(fi,a,b,c);
euclid(a,b,d,x,y);
if c mod d=0 then writeln(fo,x*(c div d),' ',y*(c div d))
else writeln(fo,'0 0');
end;
close(fi);
close(fo);
end.