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 ...
随机推荐
- ionic-CSS:ionic 网格(Grid)
ylbtech-ionic-CSS:ionic 网格(Grid) 1.返回顶部 1. ionic 网格(Grid) ionic 的网格(Grid)和其他大部分框架有所不同,它采用了弹性盒子模型(Fle ...
- 3. Image Structure and Generation
名词 Extensible Linking Format(ELF) 3.1 The structure of an ARM ELF image ARM ELF映像包含sections, regions ...
- 12-FileZilla-响应:550 Permission denied
window系统安装FileZilla与虚拟机上的Ubuntu传输文件: 状态:连接正常 问题:传输文件失败 报错:550 Permission denied 解决方法: 这是由于ftp服务器配置的问 ...
- 【python】并集交集
set是用来去重的. 在list里使用union函数.这种方式不适用于元素为字典的. list(set(a)^set(b)) 这是求差集 所以交集就是并集和ab的差集. import random d ...
- Apsara Clouder基础技能认证:阿里巴巴编码规范 考试备考题库
考试网址: https://edu.aliyun.com/clouder/exam/intro/33 共50道题 限时90分钟 阿里云大学Apsara Clouder基础技能认证——阿里巴巴编码规范认 ...
- Red Hat Linux安装vsftpd
一.安装分区方案: (1)交换分区,两倍内存 (2)/boot分区 (3)/剩余的所有空间语言选择English(英语) 二. 配置IPIP地址.子网掩码: 编辑 /etc/sysconfig/net ...
- Web前端开发必备手册(Cheat sheet)
转自:http://blog.bingo929.com/cheat-sheets-for-web-develop.html Cheat sheet这个词组如果直译成中文,意思大概是”作弊小抄”之类的词 ...
- javascript面向对象编程笔记(函数之闭包)
3 函数 3.5 闭包(closures) 3.5.1 作用域链 与很多程序设计语言不同,javascript不存在大括号级的作用域,但它有函数作用域,即在函数内定义的变量在函数外是不可见的.但如果该 ...
- 360自动抢票还不够,几行js代码设置无人值守
360就是牛逼哄哄的...... 但是最近在使用360浏览器抢票的时候还是发现了一些体验不好的地方,比如搞着搞着就退出了登录,有时候能帮你自动登录进去,但是自动登录之后又不会帮你自动开始抢.然后验证码 ...
- 关于FR4板一些重复的数据
介电常数:4.2-4.7 信号传输速度:表层 140~170 ps/inch, 内层 180 ps/inch