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 ...
随机推荐
- Developing a Custom Membership Provider from the scratch, and using it in the FBA (Form Based Authentication) in SharePoint 2010
//http://blog.sharedove.com/adisjugo/index.php/2011/01/05/writing-a-custom-membership-provider-and-u ...
- matlab里的nargin
nargin是用来判断输入变量个数的函数,这样就可以针对不同的情况执行不同的功能.
- NYOJ-71 独木舟上的旅行 (贪心)
独木舟上的旅行 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 进行一次独木舟的旅行活动,独木舟可以在港口租到,并且之间没有区别.一条独木舟最多只能乘坐两个人,且乘客 ...
- 对SNS网站现状和未来的一些想法——以我对人人网的体验为例
现在对人人网越来越没有兴趣了,上面的照片.状态也越来越少了,反而是朋友圈里大家比较活跃. 我觉得在网上发内容的,至少是希望得到大家关注的,可是为什么人人越来越被大家嫌弃了呢? 人人上的消息越来越被淹没 ...
- web开发路径问题
1. web开发路径问题总结: http://www.cnblogs.com/tianguook/archive/2012/08/31/2665755.html 2. JSP/SERVLET 路径问题 ...
- 转:应用JMeter测试solr请求
使用JMeter测试solr请求 一.安装JMeter 在官网http://jmeter.apache.org/download_jmeter.cgi下载JMeter 直接解压JMeter安装包 Li ...
- 当引用了Properties.Settings后,如果执行的时候,出现"配置系统无法初始化" 或者 某某节点不正确
自定义了一个 PowerConfig命名空间 PowerSettings.Settings 然后一个exe,引用了该dll,在app.cinfig里增加了配置项 <applicationSe ...
- 三层交换机配置说明(华为S5700设置三个网段互通)
1.配置Switch # 创建VLAN <HUAWEI> system-view[HUAWEI] sysname Switch[Switch] vlan batch 10 20 30# 配 ...
- MySQL 出现 The table is full 的解决方法【转】
[MySQL FAQ]系列 — 你所不知的table is full那些事 时间 2014-08-21 12:18:56 MySQL中文网 原文 http://imysql.com/2014/08 ...
- VituralBox 虚拟机网路设置 主机无线
主机和虚拟机都关闭防火墙 主机和虚拟机可以互相ping通 主机和虚拟机都可以联网 如果出现 ‘device not managed by NetworkManager’ 错误 network服务器 ...