Pagini recente » Cod sursa (job #2395021) | Cod sursa (job #840405) | Cod sursa (job #119801) | Cod sursa (job #307171) | Cod sursa (job #528756)
Cod sursa(job #528756)
var
t,a,b,c:longint;
procedure eextins(a,b:longint; var d,x,y:longint);
var
x0,y0:longint;
begin
if b=0 then
begin
d:=a;
x:=1;
y:=0;
end
else
begin
x0:=0; y0:=0;
eextins(b,a mod b,d,x0,y0);
x:=y0;
y:=x0-(a div b)*y0;
end
end;
procedure citire;
var
i,d,x,y:longint;
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);
x:=0; y:=0;
eextins(a,b,d,x,y);
if (c/d) = trunc(c/d) then
writeln(x*(c/d):0:0,' ',y*(c/d):0:0)
else writeln(0,' ',0);
end;
close(input);
close(output);
end;
begin
citire;
end.