链接

题目说给你n个水箱,初始是没有水的,每个的高低位置可能不同,给了你初始的水箱底部所处的水平线位置,问给你V体积水时,水的水平线位置。

直接二分位置p,对于每一个底部低于水平线位置的水箱,里面的水的体积 = min(h,p-b)*w*d;

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 50005
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct node
{
int b,h,w,d;
}p[N];
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
double cal(double mid,int n)
{
int i;
double s = ;
for(i = ; i <=n;i++)
{
if(p[i].b>mid) continue;
s+=min(mid-p[i].b,p[i].h*1.0)*p[i].w*p[i].d;
}
return s;
}
int main()
{
int v,n,i,t;
cin>>t;
while(t--)
{
scanf("%d",&n);
double s = ;
for(i = ; i <=n; i++)
{
scanf("%d%d%d%d",&p[i].b,&p[i].h,&p[i].w,&p[i].d);
s+=p[i].h*p[i].w*p[i].d;
}
scanf("%d",&v);
if(dcmp(v-s)>)
{
puts("OVERFLOW");
continue;
}
double rig = 2000000.0,lef = ,mid;
while(rig-lef>eps)
{
mid = (rig+lef)/2.0;
if(dcmp(cal(mid,n)-v)>=)
rig = mid;
else lef = mid;
}
printf("%.2f\n",rig);
}
return ;
}

poj1434Fill the Cisterns!(二分)的更多相关文章

  1. 狗狗40题~ (Volume C)

    A - Triangles 记忆化搜索呗.搜索以某三角形为顶的最大面积,注意边界情况. #include <stdio.h> #include <cstring> #inclu ...

  2. POJ 1434 Fill the Cisterns! (模拟 or 二分)

    Fill the Cisterns! 题目链接: http://acm.hust.edu.cn/vjudge/contest/129783#problem/F Description During t ...

  3. poj1434 Fill the Cisterns!

    地址:http://poj.org/problem?id=1434 题目:Fill the Cisterns! Fill the Cisterns! Time Limit: 5000MS   Memo ...

  4. BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]

    1012: [JSOI2008]最大数maxnumber Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 8748  Solved: 3835[Submi ...

  5. BZOJ 2756: [SCOI2012]奇怪的游戏 [最大流 二分]

    2756: [SCOI2012]奇怪的游戏 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 3352  Solved: 919[Submit][Stat ...

  6. 整体二分QAQ

    POJ 2104 K-th Number 时空隧道 题意: 给出一个序列,每次查询区间第k小 分析: 整体二分入门题? 代码: #include<algorithm> #include&l ...

  7. [bzoj2653][middle] (二分 + 主席树)

    Description 一个长度为n的序列a,设其排过序之后为b,其中位数定义为b[n/2],其中a,b从0开始标号,除法取下整. 给你一个长度为n的序列s. 回答Q个这样的询问:s的左端点在[a,b ...

  8. [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二

    Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...

  9. [LeetCode] Closest Binary Search Tree Value 最近的二分搜索树的值

    Given a non-empty binary search tree and a target value, find the value in the BST that is closest t ...

随机推荐

  1. HDU 4315:Climbing the Hill(阶梯博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:有n个人要往坐标为0的地方移动,他们分别有一个位置a[i],其中最靠近0的第k个人是king,移动的 ...

  2. shell基础二十篇 一些笔记

    shell基础二十篇 转自 http://bbs.chinaunix.net/thread-452942-1-1.html 研讨:Bash 内建命令 read (read命令更具体的说明见博客收藏的一 ...

  3. 计算机学院大学生程序设计竞赛(2015’12)Polygon

    Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  4. c#中委托和事件(续)(转)

    本文将讨论委托和事件一些更为细节的问题,包括一些大家常问到的问题,以及事件访问器.异常处理.超时处理和异步方法调用等内容. 为什么要使用事件而不是委托变量? 在 C#中的委托和事件 中,我提出了两个为 ...

  5. 调试器不能连接到STM32的问题与解决办法

    很多人都碰到过调试器不能连接到STM32的问题,不管是IAR的J-Link还是Keil的ULink,或者是ST的ST-Link.出现这个问题时,调试软件会提示不能建立与Cortex-M3的连接,或提示 ...

  6. winform中利用反射实现泛型数据访问对象基类(3)

    继续完善了几点代码 满足没有主键的情况下使用 并且完善实体字段反射设置value时的类型转换 /// <summary> /// DAO基类 实体名必须要与数据表字段名一致 /// < ...

  7. 造字工房情书体MFQingShu_Noncommercial-Regular

    造字工房情书体由造字工房字体设计师成瑜历时半年书写完成,其字形俊秀.遒劲有力,优雅中透出知性的气息.文从字顺,字形笔画柔美俊秀.刚柔并济,结构自然洒脱,充满活力朝气的青春气息,完美呈现了手写汉字之美, ...

  8. COGS502. 长路上的灯

    502. 长路上的灯 ☆   输入文件:light.in   输出文件:light.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] 在一条无限长的路上,有一排无限长的路 ...

  9. 收集的55个Linux系统管理中常用的一些shell命令

    .显示消耗内存/CPU最多的10个进程 代码如下: | tail | tail .查看进程 按内存从大到小排列 代码如下: ps -e -o "%C : %p : %z : %a" ...

  10. Listview的闪烁问题

    在更新Listview数据时会出现闪烁,主要原因是没有开启双缓冲属性,在C#中可以通过重载Listview的方式开启,代码如下: using System.Windows.Forms; public ...