Bob wants to pour water


Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

There is a huge cubiod house with infinite height. And there are some spheres and some cuboids in the house. They do not intersect with others and the house. The space inside the house and outside the cuboids and the spheres can contain water.

Bob wants to know when he pours some water into this house, what's the height of the water level based on the house's undersurface.

Input

The first line is a integer T (1 ≤ T ≤ 50), the number of cases.

For each case:

The first line contains 3 floats wl (0 < wl < 100000), the width and length of the house, v (0 < v < 1013), the volume of the poured water, and 2 integers, m (1 ≤ m ≤ 100000), the number of the cuboids, n (1 ≤ n ≤ 100000), the number of the spheres.

The next m lines describe the position and the size of the cuboids.

Each line contains z (0 < z < 100000), the height of the center of each cuboid, a (0 < a < w), b (0 < b < l), c, the width, length, height of each cuboid.

The next n lines describe the position and the size of the spheres, all these numbers are double.

Each line contains z (0 < z < 100000), the height of the center of each sphere, r (0 < 2r < w and 2r < l), the radius of each sphere.

Output

For each case, output the height of the water level in a single line. An answer with absolute error less than 1e-4 or relative error less than 1e-6 will be accepted. There're T lines in total.

Sample Input

1
1 1 1 1 1
1.5 0.2 0.3 0.4
0.5 0.5

Sample Output

1.537869

Author: YANG, Xinyu; ZHAO, Yueqi

题意:给出一个长为l,宽为w,无限高的长方体,这个长方体,然后给出若干的球或长方体,给出它们的各种参数(包括高度),所有的球和长方体都是不重叠的(废话)

问导入v的体积的水,问水面高度多少。

分析:根据数据范围显然是一道二分水面高度,暴力验证的题目

算球的缺体的公式可以用球面锥的面积(指在球面那部分的面积)与球面面积的比减去圆锥的体积得到

球面锥的面积:2piRH,H为半径减去球心到圆锥地面的距离

没什么trick

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name) {
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint() {
int Ret = ;
char Ch = ' ';
while(!(Ch >= '' && Ch <= '')) Ch = getchar();
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Ret;
} const int N = ;
const DB pi = acos(-1.0), Eps = 1e-;
struct Sphere {
DB High, R; inline void Read() {
scanf("%lf%lf", &High, &R);
} inline DB Calc(DB H) {
DB D = min(*R, max(0.0, H-High+R)), Ret;
Ret = pi*(R*D*D-D*D*D/);
return Ret;
}
} S[N];
struct Cube {
DB High, Width, Length, Height; inline void Read() {
scanf("%lf%lf%lf%lf", &High, &Width, &Length, &Height);
} inline DB Calc(DB H) {
DB D = min(Height, max(0.0, H-High+Height/2.0)), Ret;
Ret = Width*Length*D;
return Ret;
}
} C[N];
int n, m;
DB Width, Length, V, Ans; inline void Solve(); inline void Input() {
int TestNumber;
scanf("%d", &TestNumber);
while(TestNumber--) {
scanf("%lf%lf%lf%d%d", &Width, &Length, &V, &n, &m);
For(i, , n) C[i].Read();
For(i, , m) S[i].Read();
Solve();
}
} inline DB Calc(DB H) {
DB Ret = Width*Length*H;
For(i, , n) Ret -= C[i].Calc(H);
For(i, , m) Ret -= S[i].Calc(H);
return Ret;
} inline DB Work() {
DB Left = , Right = 1.0*INF, Mid, TmpV;
while(Right-Left >= Eps) {
Mid = (Right+Left)/2.0;
TmpV = Calc(Mid);
if(TmpV+Eps >= V) Right = Mid;
else Left = Mid;
}
return Right;
} inline void Solve() {
Ans = Work();
printf("%.6lf\n", Ans);
} int main() {
#ifndef ONLINE_JUDGE
SetIO("K");
#endif
Input();
//Solve();
return ;
}

ZOJ 3913 Bob wants to pour water ZOJ Monthly, October 2015 - H的更多相关文章

  1. ZOJ 3913 Bob wants to pour water

    ZOJ Monthly, October 2015 K题 二分答案+验证 #include<iostream> #include<algorithm> #include< ...

  2. ZOJ 3910 Market ZOJ Monthly, October 2015 - H

    Market Time Limit: 2 Seconds      Memory Limit: 65536 KB There's a fruit market in Byteland. The sal ...

  3. 思维+multiset ZOJ Monthly, July 2015 - H Twelves Monkeys

    题目传送门 /* 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 思维:对于当前p时间,从现在到未来穿越到过去的是有效的值,排 ...

  4. ZOJ 3908 Number Game ZOJ Monthly, October 2015 - F

    Number Game Time Limit: 2 Seconds      Memory Limit: 65536 KB The bored Bob is playing a number game ...

  5. ZOJ 3905 Cake ZOJ Monthly, October 2015 - C

    Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One ...

  6. ZOJ 3911 Prime Query ZOJ Monthly, October 2015 - I

    Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a s ...

  7. ZOJ 3903 Ant ZOJ Monthly, October 2015 - A

    Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going ...

  8. Twelves Monkeys (multiset解法 141 - ZOJ Monthly, July 2015 - H)

    Twelves Monkeys Time Limit: 5 Seconds      Memory Limit: 32768 KB James Cole is a convicted criminal ...

  9. 143 - ZOJ Monthly, October 2015 I Prime Query 线段树

    Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a s ...

随机推荐

  1. Unity 3D 粒子系统的一点经验

    http://hunterwang.diandian.com/post/2012-10-21/40041523890 最近做东西需要增加效果,简单的运用了一下粒子效果,真心感觉比较难调整好效果.同时也 ...

  2. CUDA中的Toolkit

    CUDA Toolkit是什么? 对于使用 C 语言和 C++ 来开发 GPU 加速应用程序的开发者来说,NVIDIA CUDA Toolkit 可提供一个综合的开发环境.CUDA Toolkit 包 ...

  3. JAVA 中BIO,NIO,AIO的理解

    [转自]http://qindongliang.iteye.com/blog/2018539 ?????????????????????在高性能的IO体系设计中,有几个名词概念常常会使我们感到迷惑不解 ...

  4. Rotate String

    Given a string and an offset, rotate string by offset. (rotate from left to right) Example Given &qu ...

  5. 解决虚拟机 正在决定eht0 的ip信息失败 无链接-- 添加虚拟网卡

    添加步骤:1.进入设备管理器 2.点下一步3.继续下一步 4.继续往下走

  6. XP 之后, Delphi 动注册表不方便了...逼出来一个办法:

    XP 之后, Delphi 动注册表不方便了...逼出来一个办法: 手头的程序需要修改注册表, 以让当前程序成为某格式的默认打开程序并关联图标; Vista 之后需要管理员权限才能操作注册表, 很麻烦 ...

  7. canvas API ,通俗的canvas基础知识(六)

    这篇是canvas API系列的首尾之作,这篇以后,所有的canvas的属性和方法就将完了,哦,不对,应该是大部分常用的,还有部分不常用的属性和方法,因为种种原因,就不介绍了,后期的重点就是多写一点c ...

  8. 【转载】C++ 值传递、指针传递、引用传递详解

    原文链接:http://www.cnblogs.com/yanlingyin/ 值传递: 形参是实参的拷贝,改变形参的值并不会影响外部实参的值.从被调用函数的角度来说,值传递是单向的(实参->形 ...

  9. decltype

    在C++中,decltype作为操作符,用于查询表达式的数据类型.decltype在C++11标准制定时引入,主要是为泛型编程而设计,以解决泛型编程中,由于有些类型由模板参数决定,而难以(甚至不可能) ...

  10. SQL 函数

    一.数学函数 数学函数主要用于处理数字,包括整型.浮点数等. ABS(x) 返回x的绝对值 SELECT ABS(-1) -- 返回1 CEIL(x),CEILING(x) 返回大于或等于x的最小整数 ...