Pagini recente » Cod sursa (job #2947621) | Cod sursa (job #229696) | Cod sursa (job #1455231) | Cod sursa (job #211484) | Cod sursa (job #1299771)
program euclidextins;
var
t,i:byte;
a,b,c,x,y,d,e,xp,yp:longint;
f,g:text;
function cmmdc(a,b:longint):longint;
begin
if a mod b=0 then
begin
xp:=1;
yp:=0;
cmmdc:=b;
end
else cmmdc:=cmmdc(b,a mod b);
x:=yp;
y:=xp-(a div b)*yp;
xp:=x;
yp:=y;
end;
begin
assign(f,'euclid3.in');
reset(f);
readln(f,t);
assign(g,'euclid3.out');
rewrite(g);
for i:=1 to t do begin
readln(f,a,b,c);
d:=cmmdc(a,b);
if (c mod d)<>0 then writeln(g,0,' ',0)
else writeln(g,x*(c div d),' ',y*(c div d));
end;
close(f);
close(g);
end.