Swimming Balls
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的更多相关文章
- Codeforces554 C Kyoya and Colored Balls
C. Kyoya and Colored Balls Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d ...
- 13 Balls Problem
今天讨论的是称球问题. No.3 13 balls problem You are given 13 balls. The odd ball may be either heavier or ligh ...
- Open judge C16H:Magical Balls 快速幂+逆元
C16H:Magical Balls 总时间限制: 1000ms 内存限制: 262144kB 描述 Wenwen has a magical ball. When put on an infin ...
- 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 ...
- hdu 3635 Dragon Balls(并查集)
Dragon Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- POJ 3687 Labeling Balls()
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9641 Accepted: 2636 Descri ...
- 【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 ...
- 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 ...
- Labeling Balls 分类: POJ 2015-07-28 19:47 10人阅读 评论(0) 收藏
Labeling Balls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11893 Accepted: 3408 Descr ...
随机推荐
- Lvs+keepalived+mysql(主从复制)
1.准备环境 操作系统:centos 6.5 2台机器主机名为node53.node54 Mysql Lvs keepalived node2 Y Y Y node3 Y Y Y ...
- 在Word中如何自动生成参考文献引用
来自:在Word中如何自动生成参考文献引用 在写毕业论文时,参考文献动辄就有四五十篇,在文中对照参考文献逐一引用是一件十分痛苦的事情,而且一旦参考文献的顺序发生变化,文中的引用也要逐个修改,那么,我们 ...
- nodejs中命令行和node交互模式的区分
来自:廖雪峰教程 么么哒~ 命令行模式和Node交互模式 请注意区分命令行模式和Node交互模式. 看到类似C:\>是在Windows提供的命令行模式: 在命令行模式下,可以执行node进入No ...
- sklearn中回归器性能评估方法
explained_variance_score() mean_absolute_error() mean_squared_error() r2_score() 以上四个函数的相同点: 这些函数都有一 ...
- mysql 数据库基本命令
停止mysql服务:net stop mysql //管理员方式运行 启动mysql服务:net start mysql 进入数据库:mysql -u root -p 查看数据库:show ...
- IOS配置cocos2d-x
cd /Users/wyc/Desktop/cocos2d-x-3.16/tools/cocos2d-console/bin python cocos.py new HelloWorldDemo -p ...
- sql(2) DISTINCT
SELECT DISTNCT 列名称 FROM 表名称SQL SELECT DISTINCT 语句在表中,可能会包含重复值. 关键词 DISTINCT 用于返回唯一不同的值. 语法:新建数据库 tes ...
- Linux sed -i 字符串替换
sed -i 直接替换文件中的内容不输出, 如 将 laravel .env中的 QUEUE_DRIVER=sync 替换为 QUEUE_DRIVER=redis, 在Laravel的项目根目录中运行 ...
- java排序,冒泡排序,选择排序,插入排序,快排
冒泡排序 时间复杂度:O(n^2) 空间复杂度O(1) 稳定性:稳定 比较相邻的元素.如果第一个比第二个大,就交换他们两个. 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对.这步做完后,最 ...
- [JZOJ2866] 【集训队互测 2012】Bomb
题目 题目大意 给你一个有\(n\)个点的平面. 选择三个点,求两两之间曼哈顿距离和的最大值和最小值. 思考历程&正解 比赛的时候没有想太多,但感觉似乎比较水-- 首先有个很显然的性质,答案为 ...