Pagini recente » Cod sursa (job #853757) | Cod sursa (job #2219851) | Cod sursa (job #2064950) | Cod sursa (job #1366947) | Cod sursa (job #1417614)
const
f1='euclid3.in';
f2='euclid3.out';
var
t,l:byte;
a,b,c,d,x,y:int64;
procedure euclid(a,b:int64; var d,x,y:int64);
var x1,y1:int64;
begin
if b=0 then
begin
d:=a;
x:=1;
y:=0;
end
else
begin
euclid(b,a mod b,d,x1,y1);
x:=y1;
y:=x1-(a div b)*y1;
end;
end;
begin
assign(input,f1); reset(input);
assign(output,f2); rewrite(output);
readln(t);
for l:=1 to t do begin
readln(a,b,c);
euclid(a,b,d,x,y);
if c mod d<>0 then writeln(0,#32,0)
else
begin
x:=x*(c div d);
y:=y*(c div d);
writeln(x,#32,y);
end;
end;
close(input);
close(output);
end.