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 ...
随机推荐
- MySQL5.5.源码安装
MySQL5.5.34安装需要用到cmke ncurses-devel yum install -y ncurses-devel cmake gcc gcc-c++ bison 下载http://m ...
- FbinstTool(U盘启动盘制作工具) v1.606 免费绿色版
软件名称: FbinstTool(U盘启动盘制作工具) v1.606 免费绿色版软件语言: 简体中文授权方式: 免费软件运行环境: Win7 / Vista / Win2003 / WinXP / W ...
- javacript没有多维数组只能模拟?
为什么说javacript没有多维数组只能模拟?但是我看到是可以实现多维数组的啊!这是为什么呢?下面我们来实验下. <!DOCTYPE html> <html lang=" ...
- 【实验室笔记】C#上位机学习笔记
用C#编写上位机,基本流程是[1]串口配置,[2]串口发送数据,[3]串口接收数据. [1]串口配置 串口的属性配置包括: No.1串口端口号 No.2串口波特率 No.3串口数据位 No.4串口停止 ...
- 3g 上网卡使用
控制面板\网络和 Internet\网络连接每个USB孔都会分配网路名 --cisco vpn 连接问题解决 启动(以管理员身份运行) sc stop SharedAccess ---完美解决win7 ...
- Redis4- llist的操作
数据类型List链表(1)介绍list类型其实就是一个双向链表.通过push,pop操作从链表的头部或者尾部添加删除元素.这使得list既可以用作栈,也可以用作队列.该list链表类型应用场景:获得最 ...
- JSP 之国际化
导入 <%@ taglib url="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 创建三个语 ...
- Flask -- 使用数据库(Sqlite3)、用户注册、登录注销、修改密码
# 使用sqlite数据库 import sqlite3from contextlib import closing app.config.update( DATABASE = 'my.db', #相 ...
- Cv图像处理
http://wiki.opencv.org.cn/index.php/Cv%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86 看看知识点,虽然是C 版本.
- OpenCV:二值图像连通区域分析与标记算法实现
http://blog.csdn.net/cooelf/article/details/26581539?utm_source=tuicool&utm_medium=referral Open ...