|
|
вернуться в форумMy O(1) solution And,here it is: program wx; var i,j,k,m,n:longint; b,c,s,t:extended; begin readln(n,c); dec(n); m:=trunc(sqrt(c)); if m>=n then begin writeln('0.00'); exit; end; if c/m<=m+1 then begin b:=m+c/m; s:=n*n-b*n+c; end else s:=1e100; inc(m); if c/m>=m-1 then begin b:=m+c/m; t:=n*n-b*n+c; end else t:=1e100; if s<t then writeln(s:0:2) else writeln(t:0:2); end. |
|
|