Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
忍不住帖个程序In Reply To:centimeter(0.01) Posted by:abccbac at 2005-08-04 19:13:44 var a,b,l,min:extended; n,k,i,j:longint; s:array[1..20000] of extended; function ok:boolean; var i,w:longint; begin w:=0; for i:=1 to n do w:=w+trunc(s[i]/l); if w>=k then ok:=true else ok:=false; end; function same(x,y:extended):boolean; begin if abs(x-y)<0.001 then same:=true else same:=false; end; begin readln(n,k); for i:=1 to n do readln(s[i]); min:=maxlongint; for i:=1 to n do if s[i]<min then min:=s[i]; a:=0; b:=min; repeat l:=(a+b)/2; if ok then a:=l else b:=l; if same(a,b) then break; until a>b; writeln(a:0:2); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator