Pagini recente » Cod sursa (job #3194496) | Cod sursa (job #2637620) | Cod sursa (job #1480530) | Cod sursa (job #1962636)
Program EuclidExt;
type maxt = -1000000000 .. 1000000000;
maxc = -2000000000 .. 2000000000;
var d,a,b,x,y : maxt;
c: maxc;
t,i: 0..100;
f,g : text;
function cmmdc (a,b:maxt;var x,y : maxt):maxt;
var c,x0,y0 : maxt;
begin
if b = 0 then begin
x:=1;
y:=0;
cmmdc := A;
exit;
end else
c:= cmmdc(b,(a mod b),x0,y0);
x:= y0;
y:= x0 - (a div B) * y0;
cmmdc:= c;
exit;
end;
begin
//assign(f,'euclid3.in');
//assign(g,'euclid3.out');
//reset(f);
//rewrite(g);
readln(T);
for i:=1 to T do begin
readln({f,}a,b,c);
d:= cmmdc(a,b,x,y);
if c mod d = 0 then begin
writeln({g,}x*(c/d),' ',y*(c/D));
end else begin
writeln({g,}'0 0');
end;
end;
//close(f);
//close(g);
end.