Pagini recente » Cod sursa (job #2345589) | Cod sursa (job #361361) | Cod sursa (job #3187096) | Cod sursa (job #480479) | Cod sursa (job #1169186)
program euclid_extins;
var a,b,c,d,x,y,t: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(input,'euclid3.in');
assign(output,'euclid3.out');
reset(input);
rewrite(output);
readln(t);
while t>0 do
begin
readln(a,b,c);
euclid(a,b,d,x,y);
if c mod d<>0 then writeln('0 0')
else writeln(x*(c div d),' ',y*(c div d));
dec(t);
end;
close(output);
end.