Pagini recente » Cod sursa (job #1728115) | Cod sursa (job #946073) | Cod sursa (job #1627939) | Cod sursa (job #311469) | Cod sursa (job #543261)
Cod sursa(job #543261)
var t,i,a,b,c,d,x,y:longint;
f1,f2:text;
function euclid(a,b:longint; var x,y:longint):longint;
var x0,y0:longint;
begin
if b=0 then
begin
euclid:=a;
x:=1;
y:=0;
end
else
begin
euclid:=euclid(b,a mod b,x0,y0);
x:=y0;
y:=x0-(a div b)*y0;
end;
end;
begin
assign(f1,'euclid3.in');
assign(f2,'euclid3.out');
reset(f1);
rewrite(f2);
readln(f1,t);
for i:=1 to t do
begin
readln(f1,a,b,c);
d:=euclid(a,b,x,y);
if c mod d=0 then writeln(f2,x*(c div d),' ',y*(c div d))
else writeln(f2,'0 0');
end;
close(f1);
close(f2);
end.