Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

忍不住帖个程序

Posted by Failed_JiangLY at 2005-08-04 19:29:40 on Problem 1064
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator