ZOJ 3913 Bob wants to pour water ZOJ Monthly, October 2015 - H

时间:2022-09-25 14:20:19

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&comma; October 2015 - H

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

  3. 思维&plus;multiset ZOJ Monthly&comma; July 2015 - H Twelves Monkeys

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

  4. ZOJ 3908 Number Game ZOJ Monthly&comma; 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&comma; 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&comma; 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&comma; October 2015 - A

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

  8. Twelves Monkeys &lpar;multiset解法 141 - ZOJ Monthly&comma; July 2015 - H&rpar;

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

  9. 143 - ZOJ Monthly&comma; October 2015 I&Tab;Prime Query 线段树

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

随机推荐

  1. vue&period;js 1中父组件跳到子组件中并传参让子组件显示不同的内容

    父组件中的点击跳转: <ul class="insurance-entry clearfloat"> <li v-link="{name:'produc ...

  2. angularjs 指令(directive)详解&lpar;1&rpar;

    原文地址 什么是directive?我们先来看一下官方的解释: At a high level, directives are markers on a DOM element (such as an ...

  3. Android程序架构基本内容概述

    在Android操作系统中开发的应用程序都有一个结构缜密的架构.我们今天就来对这一Android程序架构做一个详细的分析.帮助大家了解程序开发的特点,以方便将来在应用程序开中明确自己的程序架构. An ...

  4. SharePoint 2010 获取当前用户的权限

    转:http://blog.csdn.net/sygwin_net/article/details/6790500 操作环境:SharePoint 2010 关于SharePoint 的权限架构,具体 ...

  5. Python中 if &lowbar;&lowbar;name&lowbar;&lowbar; &equals;&equals; &&num;39&semi;&lowbar;&lowbar;main&lowbar;&lowbar;&&num;39&semi;&colon; 详解

    一个python文件就可以看作是一个python的模块,这个python模块(.py文件)有两种使用方式:直接运行和作为模块被其他模块调用. __name__:每一个模块都有一个内置属性__name_ ...

  6. &lbrack;Webpack 2&rsqb; Hashing with Webpack for long term caching

    Leveraging the browser cache is an important part of page load performance. A great way to utilize t ...

  7. C&num;的百度地图开发&lpar;二&rpar;转换JSON数据为相应的类

    原文:C#的百度地图开发(二)转换JSON数据为相应的类 在<C#的百度地图开发(一)发起HTTP请求>一文中我们向百度提供的API的URL发起请求,并得到了返回的结果,结果是一串JSON ...

  8. 微信小程序 PHP后端form表单提交实例详解

    微信小程序php后端form表单 https://www.cnblogs.com/tdalcn/p/7092716.html 1.小程序相对于之前的WEB+PHP建站来说,个人理解为只是将web放到了 ...

  9. ARDC连接设备异常之ADB version mismatch的处理

    如果ARDC提示ADB version mismatch,说明系统当前运行的adb server与client不匹配.此时如果在cmd.exe中运行adb devices命令则会出现类似如下的提示信息 ...

  10. IOS返回go&lpar;-1&rpar;

    IOS8和9,在用go(-1)返回的时候,会同时加载js.可能会造成js加载顺序出错,或者值被覆盖的情况,我们可以用setTimeout(function(){XXX代码},100);延时加载.