NKSTEP - Chuyển

Tác giả: flashmt

Ngôn ngữ: Pascal

var i,x,y,t,n,k:longint;
begin
     readln(t);
     for i:=1 to t do
     begin
          readln(x,y);
          n:=abs(y-x);
          k:=trunc(sqrt(n));
          while k*(k+1)<n do inc(k);
          dec(k);
          if n-k*(k+1)>k+1 then writeln(k*2+2)
          else writeln(k*2+1);
     end;
end.

Download