Pagini recente » Cod sursa (job #943215) | Cod sursa (job #358983) | Cod sursa (job #896628) | Cod sursa (job #1105991) | Cod sursa (job #1418919)
program euclid;
var a,b,x,y,z,d,n,i,c:longint;
f1,f2:text;
function gcd(a,b:longint):longint;
var x0,y0,d:longint;
begin
if b=0 then begin x:=1; y:=0; gcd:=a; end else begin
gcd:=gcd(b,a mod b);
z:=x; x:=y;
y:=z-(a div b)*y;
end;
end;
begin
assign (f1,'euclid3.in');
assign (f2,'euclid3.out');
reset (f1);
rewrite (f2);
readln (f1,n);
for i:=1 to n do begin
readln (f1,a,b,c);
d:=gcd(a,b);
if c mod d<>0 then writeln (f2,0,' ',0) else
writeln (f2,(c div d)*x,' ',(c div d)*y);
end;
close (f1);
close (f2);
end.