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 xiaotianwei at 2010-12-27 11:05:26 on Problem 1064
#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:
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