POJ 1434 二分
来源:互联网 发布:创维25nd9000总线数据 编辑:程序博客网 时间:2024/05/29 13:20
题意:给出离地高度b,和水箱的长宽高,给出水的容积,问装完水有多高。
二分高度,裸二分。
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;struct cistern{ double b,h,w,d;} data[50005];int n,t;double getans(double h){ double sum=0; for(int i=0; i<n; i++) if(h>data[i].b) sum+=h>data[i].b+data[i].h?data[i].h*data[i].w*data[i].d:data[i].w*data[i].d*(h-data[i].b); return sum;}int main(){ double sum,ans,h; scanf("%d",&t); while(t--) { sum=h=0; scanf("%d",&n); for(int i=0; i<n; i++) scanf("%lf%lf%lf%lf",&data[i].b,&data[i].h,&data[i].w,&data[i].d), sum+=data[i].h*data[i].w*data[i].d, h=max(h,data[i].b+data[i].h); scanf("%lf",&ans); if(ans>sum) { puts("OVERFLOW"); continue; } double l=0,r=h,mid; while(l<=r) { mid=(l+r)/2.0; double x1=getans(mid),x2=getans(mid-1e-4); if(x1>=ans&&x2<ans) break; else if(x1<ans) l=mid+1e-4; else r=mid-1e-4; } printf("%.2f\n",mid); } return 0;}
- POJ 1434 二分
- poj 1434 Fill the Cisterns! (二分)
- POJ 1434 Fill the Cisterns!(二分)
- POJ 1434 Fill the Cisterns!(二分)
- POJ 1434 Fill the Cisterns!(二分)
- POJ 1434 Fill the Cisterns!(二分)
- poj (3343)二分匹配+二分
- POJ 3233 二分二分矩阵
- poj 3685 二分套二分
- poj 3685 二分套二分
- POJ 二分算法
- POJ 3258 二分算法
- poj 2060 二分匹配
- poj 3273 (二分)
- poj 3273(二分。。。很水。。。。)
- poj 3258(二分。。。)
- poj 1693 二分图
- POJ 3122 Pie 二分
- 制作initramfs镜像
- Qt在ubuntu下报cannot connect creator comm sokcet /tmp/qt_temp.cQ2531/stub-socket原因
- 无锁HashMap的原理与实现
- 找不到或无法加载主类
- 【鸟枪当炮 PowerPoint玩刻录】
- POJ 1434 二分
- hdu 1003 Max Sum
- 【WPS快速调整从网上复制的零乱文字】
- 学习Cocos2D-x之路(2)--学习第一个例子
- mfs 分布式文件系统
- SSI开发:spring-pool.xml标准配置模板
- 策略模式
- 个人日记
- 【C# 相关】