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的更多相关文章

  1. 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 ...

  2. LintCode——Pour Water

    Pour Water: We are given an elevation map, heights[i] representing the height of the terrain at that ...

  3. ZOJ 3632 K - Watermelon Full of Water 优先队列优化DP

    K - Watermelon Full of Water Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld &am ...

  4. [LeetCode] Pour Water 倒水

    We are given an elevation map, heights[i] representing the height of the terrain at that index. The ...

  5. LeetCode 755. Pour Water

    原题链接在这里:https://leetcode.com/problems/pour-water/description/ 题目: We are given an elevation map, hei ...

  6. zoj 2974 Just Pour the Water矩阵快速幂

    Just Pour the Water Time Limit: 2 Seconds      Memory Limit: 65536 KB Shirly is a very clever girl. ...

  7. 【ZOJ】3740:Water Level【DP】

    Water Level Time Limit: 2 Seconds      Memory Limit: 65536 KB Hangzhou is a beautiful city, especial ...

  8. [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 ...

  9. [LeetCode] Trapping Rain Water 收集雨水

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

随机推荐

  1. Python从json中提取数据

    #json string:s = json.loads('{"name":"test", "type":{"name": ...

  2. SpringMVC集成shrio框架

    使用SHIRO的步骤:1,导入jar2,配置web.xml3,建立dbRelm4,在Spring中配置 添加所需jar包: <!--Apache Shiro所需的jar包--> <d ...

  3. 关于dubbo服务产生异常之:Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer.

    简单来说就是dubbo超时,因为dubbo默认的时间是500ms,超过这个时间它会重新访问service层,最多尝试三次. 所以我在测试的时候日志显示出来的异常为……timeout……. 开始设置开始 ...

  4. [PHP] 安装和配置

    Apachehttpd-2.2.19-win64mysql5.6Phphttp://www.php.net/downloads.php 5.4Phpeclipsehttp://www.phpeclip ...

  5. 《JavaScript高级程序设计》读书笔记 ---变量、作用域和内存问题小结

    JavaScript 变量可以用来保存两种类型的值:基本类型值和引用类型值.基本类型的值源自以下5种基本数据类型:Undefined.Null.Boolean.Number 和String.基本类型值 ...

  6. C#中Bitmap类 对图像の操作 可检测图片完整性

    try { Bitmap bm = new Bitmap(pics[ip]); BitmapToBytes(bm).Reverse().Take(2); } catch (Exception ex) ...

  7. eclipse使用外部maven时multiModuleProjectDirectory错误解决

    错误提醒: -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment vari ...

  8. js 条件判断放大字体

    <html> <head> <meta charset="utf-8" /> <title></title> <s ...

  9. OpenCV成长之路:图像直方图的应用

    OpenCV成长之路:图像直方图的应用 2014-04-11 13:57:03 标签:opencv 图像 直方图 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否 ...

  10. Java编译成功,用java 运行class时出现错误解决方法

    java -classpath class file's address; filename