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 1004101213 at 2011-07-15 21:10:07 on Problem 1434
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define eps 1.0e-4
struct kk
{
    double a;
    double b;
    double c;
    double h;
    double v;
}t[60000];
bool cmp(kk c,kk d)
{
    return c.h+c.a<d.h+d.a;
}
int main()
{
    int i,k,n;
    double zv,sum,l,r,mid,mpp;
    scanf("%d",&k);
    while(k--)
    {
        sum=0;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            scanf("%lf%lf%lf%lf",&t[i].h,&t[i].a,&t[i].b,&t[i].c);
            t[i].v=t[i].a*t[i].b*t[i].c;
            sum+=t[i].v;
        }
        scanf("%lf",&zv);
        if(sum<zv){puts("OVERFLOW");continue;}
        else
        {
            sort(t,t+n,cmp);
            l=t[0].h+t[0].a;r=t[n-1].h+t[n-1].a;
            while(l<=r)
            {
                mid=(l+r)/2.0;mpp=0;
                for(i=0;i<n;i++)
                {
                    if(mid-t[i].h>=t[i].a)
                     mpp+=t[i].v;
                    if(mid>t[i].h&&mid<=t[i].h+t[i].a)
                    mpp+=t[i].b*t[i].c*(mid-t[i].h);
                }
                if(mpp<zv)l=mid+eps;
                else r=mid-eps;
            }


        }
        printf("%.2f\n",l);
    }
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