Swimming Balls
https://vjudge.net/contest/318752#problem/J
如果直接算,各种球的情况都不清楚,因为放一个球之后,水位的变化也会影响之前放入的球,不如,二分最终的水位高度,这样每个球的贡献就有了

#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)
//by war
//2019.8.16
using namespace std;
int T,n;
double L,x,y,mid,W,D,V,w[N],r[N],eps=1e-,ans,pai=3.141592653589793;
void in(int &x){
int y=;char c=getchar();x=;
while(c<''||c>''){if(c=='-')y=-;c=getchar();}
while(c<=''&&c>=''){ x=(x<<)+(x<<)+c-'';c=getchar();}
x*=y;
}
void o(int x){
if(x<){p('-');x=-x;}
if(x>)o(x/);
p(x%+'');
} double v(double r){
return 4.0000000/3.00000000*pai*r*r*r;
} double deal(double h,int i){
return pai*(r[i]*r[i]*h-h*h*h/3.0);
} double lj(double x,int i){
if(x-r[i]>eps)
return v(r[i])/2.0+deal(min(r[i],x-r[i]),i);
return v(r[i])/2.0-deal(r[i]-x,i);
} bool check(double x){
double t=V;
For(i,,n){
if(1.0000000-w[i]>eps)
t+=min(v(r[i])*w[i],lj(x,i));
else
t+=lj(x,i);
}
if(t/W/L-x>eps)
return ;
return ;
}
signed main(){
in(T);
while(T--){
in(n);
cin>>W>>L>>D>>V;
if(V<eps){
puts("0.0000000000");
continue;
}
For(i,,n)
cin>>r[i]>>w[i];
x=;y=D+eps;
while(y-x>eps){
mid=(x+y)/2.0;
if(check(mid))
x=mid;
else
y=mid;
}
printf("%.10f\n",mid);
}
return ;
}

Swimming Balls的更多相关文章

  1. Codeforces554 C Kyoya and Colored Balls

    C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d ...

  2. 13 Balls Problem

    今天讨论的是称球问题. No.3 13 balls problem You are given 13 balls. The odd ball may be either heavier or ligh ...

  3. Open judge C16H:Magical Balls 快速幂+逆元

    C16H:Magical Balls 总时间限制:  1000ms 内存限制:  262144kB 描述 Wenwen has a magical ball. When put on an infin ...

  4. hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...

  5. hdu 3635 Dragon Balls(并查集)

    Dragon Balls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  6. POJ 3687 Labeling Balls()

    Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9641 Accepted: 2636 Descri ...

  7. 【CodeForces 596A】E - 特别水的题5-Wilbur and Swimming Pool

    Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...

  8. Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)

    C time limit per test 1 second memory limit per test 256 megabytes input standard input output stand ...

  9. Labeling Balls 分类: POJ 2015-07-28 19:47 10人阅读 评论(0) 收藏

    Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11893 Accepted: 3408 Descr ...

随机推荐

  1. yolov1代码阅读

    yolov1使用的backbone是由GoogLeNet启发而来,有24个卷积层,最后接2个全连接层,详细结构如下图: 检测网络的输入分辨率是448X448,最后的特征图大小为7X7.在特征图的每一个 ...

  2. LeetCode 595. Big Countries (大的国家)

    题目标签: 题目给了我们一个 world table,让我们找出 面积大于3 million square km 或者 人口大于 25 million. 直接用两个条件搜索. Java Solutio ...

  3. git学习记录2(远程库管理)

    学习参考地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 本编随笔只是自己对 ...

  4. Day 12 :迭代器与生成器

    可迭代:在Python中如果一个对象有__iter__( )方法,则称这个对象是可迭代的(Iterable): 其中__iter__( )方法的作用是让对象可以用for ... in循环遍历,列表Li ...

  5. Neo4j使用简单例子

    Neo4j Versions Most of the examples on this page are written with Neo4j 2.0 in mind, so they skip th ...

  6. netty UnpooledHeapByteBuf 源码分析

    UnpooledHeapByteBuf 是基于堆内存进行内存分配的字节缓冲区,没有基于对象池技术实现,这意味着每次I/O的读写都会创建一个新的UnpooledHeapByteBuf,频繁进行大块内存的 ...

  7. shell 命令 文件(解)压缩 tar,zip, gzip,bzip2

    1.gzip / gunzip [ gzip data.c]  对文件进行压缩,生成 data.c.gz    同时删除了原文件    同时压缩两个文件     [gunzip  data.c.gz  ...

  8. window.onload=function(){};

    window.onload=function(){}; 只要页面加载完毕,这个事件才会触发 扩展事件--页面关闭后才触发的事件 window.onunload=function(){}; 扩展事件-- ...

  9. MySQL sql_mode 说明(及处理一起sql_mode引发的问题)

    转自:https://segmentfault.com/a/1190000005936172 1. MySQL 莫名变成了 Strict SQL Mode 最近测试组那边反应数据库部分写入失败,app ...

  10. sql (9) COUNT

    COUNT() 函数返回匹配指定条件的行数.语法SQL COUNT(column_name) 语法COUNT(column_name) 函数返回指定列的值的数目(NULL 不计入):新建表 Stude ...