|
|
back to boardCould anyone help me?(+) What could be wrong with this code? Program Easy; Const Max=10006; Var i,n,k:Longint; a:Array[1..Max] Of Longint; x,y,z:Longint; u,q:Real; Function ok(l:Longint):Boolean; Var i,s:Longint; Begin s:=0; For i:=1 To n Do s:=s+a[i] Div l; ok:=s>=k; End; Begin { Assign(Input,'1184.in'); Reset(input);{} Read(n,k); y:=10000000; For i:=1 To n Do Begin Read(u); a[i]:=Round(u*100); End; x:=1; If Not ok(x) Then Begin Writeln('0.00'); Halt; End; While y-x>1 Do Begin z:=(y+x) Div 2; If ok(z) Then x:=z Else y:=z; End; While Not ok(z) Do z:=z-1; While Ok(z+1) Do z:=z+1; q:=z; q:=q/100; Writeln(q:0:2); End. Thank you for your help, H J ! (-) |
|
|