ZOJ 3913 Bob wants to pour water
ZOJ Monthly, October 2015 K题
二分答案+验证
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std; const double pi=3.1415926535898;
const int maxn=+;
struct cuboids
{
double z;
double width,length,height;
}c[maxn];
struct sphere
{
double r;
double z;
}s[maxn];
double W,L,V;
int T,m,n;
double Min,Max,Mid;
double qiu(double r1,double h)
{
return pi/*h*(*(r1*r1+r1*r1-h*h)+h*h);
}
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf",&W,&L,&V);
scanf("%d%d",&m,&n);
double vNow=;
for(int i=;i<=m;i++)
scanf("%lf%lf%lf%lf",&c[i].z,&c[i].width,&c[i].length,&c[i].height);
for(int i=;i<=n;i++)
scanf("%lf%lf",&s[i].z,&s[i].r); Min=;
Max=V;
for(int i=;i<=m;i++)
Max=Max+c[i].width*c[i].length*c[i].height;
for(int i=;i<=n;i++)
Max=Max+4.0/3.0*pi*s[i].r*s[i].r*s[i].r;
Max=Max/(W*L);
Mid=(Min+Max)/2.0;
int t=;
while(t--)
{
vNow=W*L*Mid; for(int i=;i<=m;i++)
{
if(c[i].z-c[i].height/>=Mid)
continue;
else if(c[i].z+c[i].height/<=Mid)
vNow=vNow-c[i].width*c[i].length*c[i].height;
else
vNow=vNow-c[i].width*c[i].length*(Mid-(c[i].z-c[i].height/));
}
for(int i=;i<=n;i++)
{
if(Mid<=s[i].z-s[i].r) continue;
else if(Mid>=s[i].z+s[i].r)
vNow=vNow-4.0/3.0*pi*s[i].r*s[i].r*s[i].r;
else if(Mid>s[i].z-s[i].r&&Mid<=s[i].z)
{
vNow-=pi*s[i].r*s[i].r*s[i].r*//;
vNow+=qiu(s[i].r,s[i].z-Mid);
}
else
{
vNow-=pi*s[i].r*s[i].r*s[i].r*//;
vNow-=qiu(s[i].r,Mid-s[i].z);
}
}
if(Max-Mid<1e-) break;
if(vNow>V)
{
Max=Mid;
Mid=(Min+Max)/2.0;
}
else
{
Min=Mid;
Mid=(Min+Max)/2.0;
}
}
printf("%.6lf\n",Mid);
}
return ;
}
ZOJ 3913 Bob wants to pour water的更多相关文章
- ZOJ 3913 Bob wants to pour water ZOJ Monthly, October 2015 - H
Bob wants to pour water Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge There i ...
- LintCode——Pour Water
Pour Water: We are given an elevation map, heights[i] representing the height of the terrain at that ...
- ZOJ 3632 K - Watermelon Full of Water 优先队列优化DP
K - Watermelon Full of Water Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%lld &am ...
- [LeetCode] Pour Water 倒水
We are given an elevation map, heights[i] representing the height of the terrain at that index. The ...
- LeetCode 755. Pour Water
原题链接在这里:https://leetcode.com/problems/pour-water/description/ 题目: We are given an elevation map, hei ...
- zoj 2974 Just Pour the Water矩阵快速幂
Just Pour the Water Time Limit: 2 Seconds Memory Limit: 65536 KB Shirly is a very clever girl. ...
- 【ZOJ】3740:Water Level【DP】
Water Level Time Limit: 2 Seconds Memory Limit: 65536 KB Hangzhou is a beautiful city, especial ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] Trapping Rain Water 收集雨水
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
随机推荐
- erlang四大behaviour之四-supervisor
http://www.cnblogs.com/puputu/articles/1689621.html 1. 监督规则 一个监督者负责启动.停止.监控他的子进程.监督者的一个基本概念就是当必要的时候重 ...
- 10个男孩和n个女孩共买了n2+8n+2本书,已知他们每人买的书本的数量是相同的,且女孩人数多于南海人数,问女孩人数是多少?(整除原理1.1.3)
10个男孩和n个女孩共买了n2+8n+2本书,已知他们每人买的书本的数量是相同的,且女孩人数多于南海人数,问女孩人数是多少? 解: 因为,每个人买的书本的数量是相同的, 所以,10|n2+8n+2 所 ...
- li浮动时ul高度为0,解决ul自适应高度的几种方法
网址:http://www.gxchina.com/edu/11208.html 1.给ul元素设置高度height最直接的办法是给ul元素设置一个高度,即ul标签添加height属性,代码如下: u ...
- 阅读《大道至简第一章》读后感(java伪代码)
大道至简讲述的是软件工程实践者的思想,书的第一章引用了著名的----愚公移山这一历史故事,向我们讲述了编程的精义.汤问篇中所述的愚公移山这一事件,我们看到了原始需求的产生---“惩山北之塞,出入之迂” ...
- ios电话监听状态
#import "ViewController.h" #import <CoreTelephony/CTCallCenter.h> #import <CoreTe ...
- ASP.NET MVC 使用带有短横线的html Attributes
我们常常需要一个文本框来输入用户名,在asp.net mvc 中可以使用 TextBoxFor.有时候我们想为这个文本框添加一些特性,比如 html5 的data-,如果直接写data-是会提示错误的 ...
- set集合容器
set集合容器几条特点 1.它不会重复插入相同键值的元素,而采取忽略处理 2.使用中序遍历算法,检索效率高于vector.deque.list容器,在插入元素时,会自动将元素按键值从小到大排列 3 ...
- Java Web项目发布及使用自定义域名
详细讲解的网址: http://wenku.baidu.com/link?url=-ACZxKUcfrbhrMRUP3Ov-Q_c-Q9JPrA9D1fzHjHuJsWwZfRsVDVQ2qBtoY7 ...
- Centos下 Nginx安装与配置
网上找了好多资料.都很难找全,这里以这个目录为主,进行备注. Nginx是一款轻量级的网页服务器.反向代理服务器.相较于Apache.lighttpd具有占有内存少,稳定性高等优势.它最常的用途是提供 ...
- 【转】Ecshop 后台增加一个左侧列表菜单menu菜单的方法
cshop 后台增加一个左侧列表菜单menu菜单需要修改三个文件:/admin/includes/inc_menu.php/admin/includes/inc_priv.php/languages/ ...