| ||||||||||
| 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 | |||||||||
精度!!!!!!!!!!!#include<iostream>
#include<stdio.h>
using namespace std;
int n,k;
int len[10001];
double getmax(int l,int r)
{
while(l<=r)
{
int mid=(l+r)/2;
if(mid==0){l=mid+1;continue;}
int c=0;
for(int i=1;i<=n;i++)
{
c+=len[i]/mid;
if(c>=k)break;
}
if(c>=k)l=mid+1;
else r=mid-1;
}
return (double)(l-1);
}
int main()
{
int m;
while(scanf("%d%d",&n,&k)!=EOF)
{
m=0;
for(int i=1;i<=n;i++)
{
double l;
scanf("%lf",&l);
l+=0.005;
len[i]=(int)(l*100);
if(m<len[i])m=len[i];
}
printf("%.2lf\n",getmax(1,m)/100);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator