Pagini recente » Cod sursa (job #2057744) | Cod sursa (job #2279405) | Cod sursa (job #1450664) | Cod sursa (job #1292350) | Cod sursa (job #1211772)
program euclid_extins;
var t,i,a,b,c,x,y,z,d:longint;
function gcd(a,b:longint):longint;
begin
if b=0 then
begin
gcd:=a;
x:=1;
y:=0;
end else
begin
gcd:=gcd(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:=gcd(a,b);
if c mod d<>0 then writeln(0,' ',0)
else writeln(x*(c div d),' ',y*(c div d));
end;
close(output);
end.