Pagini recente » Cod sursa (job #2749288) | Cod sursa (job #2947691) | Cod sursa (job #3213131) | Cod sursa (job #1243495) | Cod sursa (job #226206)
Cod sursa(job #226206)
program euclid3;
var a,b,c,d: longint;
x,y: longint;
i,n: longint;
function rec_euclid(a,b:longint; var x,y:longint):longint;
var x0,y0: longint;
begin
if b=0 then
begin
x:=1; y:=0;
rec_euclid:=a;
end
else
begin
rec_euclid:=rec_euclid(b,a mod b,x0,y0);
x:=y0;
y:=x0-(a div b)*y0;
end;
end;
begin
assign(input,'euclid3.in');
reset(input);
assign(output,'euclid3.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(a,b,c);
d:=rec_euclid(a,b,x,y);
if c mod d<>0 then
writeln(0,' ',0)
else
writeln(x*(c div d),' ',y*(c div d));
{writeln(a*x+b*y);}
end;
close(input);
close(output);
end.