POJ 1434 Fill the Cisterns!(二分)
来源:互联网 发布:不会英语怎么学编程 编辑:程序博客网 时间:2024/05/22 06:55
题意:给你一些水箱的位置,以及需要装的水的体积,求水线的高度。。如果溢出则输出overflow
水题。。二分就好了
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<algorithm>using namespace std;const double eps=1e-8;int t;int n;struct sq{double high;double h,s;}q[1000000];double v;double l,r;double f(double k){double ans=0;for(int i=0;i<n;i++){if(q[i].high<k){if(q[i].high+q[i].h<=k){ans+=q[i].h*q[i].s;}elseans+=q[i].s*(k-q[i].high);}}return ans;}int main(){scanf("%d",&t);while(t--){r=0.0;l=1000000000.0;scanf("%d",&n);for(int i=0;i<n;i++){double a,b;scanf("%lf%lf%lf%lf",&q[i].high,&q[i].h,&a,&b);q[i].s=a*b;r=max(r,q[i].h+q[i].high);l=min(l,q[i].high);}scanf("%lf",&v);if(f(r)<v)printf("OVERFLOW\n");else{double m;while(fabs(l-r)>eps){m=(l+r)/2;if(f(m)>=v)r=m;elsel=m;}printf("%.2lf\n",(l+r)/2);}}return 0;}
0 0
- 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 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 1434 Fill the Cisterns!(扫描线)
- POJ 1434 Fill the Cisterns! 笔记
- POJ1434-Fill the Cisterns!
- POJ1434 Fill the Cisterns! 二分法
- poj1434Fill the Cisterns!【二分+计算几何】
- POJ_1434_Fill the Cisterns!
- 填充正方形(Fill the Square)
- uva 11520 Fill the Square(DFS)
- 麻痹的,浪费了2个月的时间,终于明白了,android网站上的help是最好的
- Netty中文用户手册(二)
- poj 2236 Wireless Network 并查集
- 2014-05-01 Arm架构的处理器模式和寄存器用途
- 7.8 VC2010下Qt5的中文乱码问题
- POJ 1434 Fill the Cisterns!(二分)
- codeforces 426B - Sereja and Mirroring
- Linux系统运行级与启动机制剖析
- 深入分析委托和事件
- 两年前实习时的文档——MMC学习总结
- nefu 643 按位异或应用
- 如何做到每天写代码
- JWS-webservice 与Axis2-webservice的快速实现
- [LeetCode] Binary Tree Zigzag Level Order Traversal