第五个点,floating point expection

P1297 [国家集训队] 单选错位

a数组开到qword,范围加到100000 ```pas uses math; var n,k,s,m,l,r:qword; i:longint; a:array[1..100000] of qword; x:extended; function pd(x:longint):boolean; var t:longint; s:qword; begin s:=0; for t:=1 to n do s:=s+a[t] div x; exit(s>=k); end; begin readln(n,k); r:=0; for i:=1 to n do begin readln(x); a[i]:=trunc(x*100); end; for i:=1 to n do s:=s+a[i]; if (s<k) then begin writeln('0.00'); halt; end; if (s=k) then begin writeln('1.00'); halt; end; l:=0; r:=10000000000000; repeat m:=(l+r) div 2; if pd(m) then l:=m+1 else r:=m-1; until l>r; writeln(r/100:0:2); end. ```
by 彭骐飞 @ 2017-05-01 12:39:11


|