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 ...
随机推荐
- POJ 2676 Sudoku(深搜)
Sudoku Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submi ...
- Python基础(四)-集合
补充: 数据类型分类: 1.按照数据可变不可变: 可变:列表.字典 不可变:数字.字符串.元组 x={':1} print(id(x)) x.update({':2}) print(x) print( ...
- md5校验问题
描述: 最近跟同事做数据对接,接收完数据,有个md5校验,发现总是对不上 首先把解密之后的明文直接写成变量在md5的工具类main函数执行,发现居然对上了, 然后测试环境debug接收的文件,md5加 ...
- winsock编程select模型
winsock编程select模型 网络服务端连接数量过多时,为每一个连接申请一个线程会让机器性能急剧下降(大多说是因为线程在用户态和内核态之间切换会占用大量的CPU时间片).为了解决多线程带来的性能 ...
- RecyclerView onTouch & onClick 触摸事件与点击事件
遇到一种情况需要处理,RecyclerView所在Activity需要处理滑动事件用于返回(onBackPressed). 手势检测: @Override public boolean onFling ...
- memcached + php 扩展 for ubuntu
1.安装memcached apt-get install memcached 2.安装php memcached 扩展 apt-get install php5-memcache 3.启动memca ...
- apk的重签名
1. 生成Android APK包签名证书 1). 在doc中切换到jdk的bin目录 cd C:\Program Files\Java\jdk1.6.0_18\bin 2). ...
- Chapter 2 Open Book——18
"Wow," Mike said. "It's snowing."I looked at the little cotton fluffs that were ...
- 其他应用和技巧-用JS实现的抽奖程序
-------------------------------- <script type="text/javascript"> var data ...
- rm删除文件时排除特定文件
删除当前目录下所有的*.txt文件,但除了test.txt文件: rm `ls *.txt | grep -v test.txt` 或者 rm `ls *.txt | egrep -v test.tx ...