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<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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator