Pagini recente » Cod sursa (job #1223930) | Cod sursa (job #1717949) | Cod sursa (job #2151091) | Cod sursa (job #3127079) | Cod sursa (job #275764)
Cod sursa(job #275764)
//euclid extins
var a,b,c,t,i,x,y,d:longint;
f,g:text;
function euclidextins(a,b:longint;var x,y:longint):longint;
var x0,y0:longint;
begin
if b=0 then begin
euclidextins:=a;
x:=1;
y:=0;
end
else begin
euclidextins:=euclidextins(b,(a mod b),x0,y0);
x:=y0;
y:=x0-(a div b)*y0;
end;
end;
begin
assign(f,'euclid3.in');reset(f);
assign(g,'euclid3.out');rewrite(g);
read(f,t);
for i:=1 to t do begin
read(f,a,b,c);
x:=0;
y:=0;
d:=euclidextins(a,b,x,y);
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.