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. JVM<一>----------运行时数据区域

    参考:1.JVM Specification: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.5 2.< ...

  2. [Effective JavaScript 笔记]第22条:使用arguments创建可变参数的函数

    第21条讲述使用可变参数的函数average.该函数可处理任意数量的参数并返回这些参数的平均值. 如何创建可变参数的函数 1.实现固定元数的函数 书上的版本 function averageOfArr ...

  3. sqlmap如何修改线程

    找到settings.py文件,具体在\lib\core\目录下找到 # Maximum number of threads (avoiding connection issues and/or Do ...

  4. 关于LINUX文件与目录的问题说明

    文件权限一般可认为是0 123 456 789,一共十位: 0:表示该文件的文件类型.Windows里面是使用了一种文件关联的技术,通过扩展名来关联相应的应用程序,使得双击某个文件,就能达到调用相应的 ...

  5. failed to load session "ubuntu"

    https://answers.launchpad.net/ubuntu/+source/gnome-desktop/+question/211792

  6. 15.含有指针成员的类的拷贝[ClassCopyConstructorWithPointerMember]

    [题目] 下面是一个数组类的声明与实现.请分析这个类有什么问题,并针对存在的问题提出几种解决方案.  C++ Code  123456789101112131415161718192021222324 ...

  7. Adobe Flash Player 因过期而遭到阻止 更新插件 运行一次 解决方法

    老机器运行 10.3.183.90 比较流畅 可是 Chrome 浏览器提示 Adobe Flash Player 因过期而遭到阻止 更新插件 运行一次 每次单击 运行一次 才运行,这样每次提醒很烦人 ...

  8. Java for LeetCode 078 Subsets

    Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must ...

  9. 重温CSS之背景、文本样式

    CSS背景样式: 背景色:background-color属性,设置元素的背景色,如:div {background:blue;}--设置所有div元素的背景为蓝色: 背景图像:background- ...

  10. MFC基于Dialog的工程中使用OSG

    osg的例子有osgviewerMFC,是MDI类型的MFC工程,我一般用基于对话框的MFC较多. 注意观察MFC_OSG.h文件中的cOSG构造函数,参数是一个窗口句柄hWnd,这里的窗口可以不只局 ...