Pagini recente » Cod sursa (job #2958321) | Cod sursa (job #1243968) | Cod sursa (job #2775918) | Cod sursa (job #672419) | Cod sursa (job #1234646)
program euclid_extins;
var a,b,c,d,x,y,z,t,i: longint;
function dc(a,b:longint):longint;
begin
if b=0 then begin
dc:=a;
x:=1;
y:=0;
end
else begin
dc:=dc(b, a mod b);
z:=x;
x:=y;
y:=z-(a div b)*y;
end;
end;
begin
assign(input, 'euclid3.in');
reset(input);
assign(output, 'euclid3.out');
rewrite(output);
readln(t);
for i:=1 to t do begin
readln(a,b,c);
d:=dc(a,b);
if c mod d<>0 then writeln(0,' ',0)
else writeln(x*(c div d),' ',y*(c div d));
end;
close(input);
close(output);
end.