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 ...
随机推荐
- 虚拟IP---Linux下一个网卡配置多个IP
转:http://blog.csdn.net/turkeyzhou/article/details/16971225 Linux下配置网卡ip别名何谓ip别名?用windows的话说,就是为一个网卡配 ...
- 黑科技之杜教bm
这个板子能够解决任何线性递推式,只要你确定某个数列的某项只与前几项线性相关,那么把它前若干项丢进去,这个板子就能给你返回你要求的某项的值. 原理???(待补充) #include<bits/st ...
- [转] boost undefined reference to 'pthread_create 问题
由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误:undefined reference to 'pthread_create'u ...
- 春节跳槽最新Java面试题及答案整理
今天大部分码农同学已经上班了吧,最近也是跳槽人才流动的高峰期,拿了年终奖,找找更好的机会. 小编也面了几家公司了,回来整理下面经分享给大家做个参考.有很多,暂时先分享20道,后续更多会陆续整理分享出来 ...
- Python-docx库的使用
from docx import Document from docx.shared import Inches document = Document() document.add_heading( ...
- python 数据结构之冒泡排序
def bubble_sort(alist): # 外层循环冒泡排序进行的次数(len-1) for i in range(len(alist) - 1, 0, -1): # 内层循环控制冒泡的比较: ...
- NuGet包介绍
Antlr 各种语言的语法识别器.解析器.编译和翻译器 Microsoft.AspNet.Web.Optimization 绑定优化CSS和JavaScript文件,也就是App_Start下的Bun ...
- CF982F The Meeting Place Cannot Be Changed
题意:给你一张有向图,某人会任意选择起点然后走无穷多步,问是否存在一个点(要求输出)不管他起点在何处怎么走都必经?n<=100005,m<=500005. 标程: #include< ...
- HashMap 什么时候进行扩容呢
HashMap扩容: 当HashMap中的元素越来越多的时候,碰撞的几率也就越来越高(因为数组的长度是固定的),所以为了提高查询的效率,就要对HashMap的数组进行扩容,数组扩容这个操作也会出现在A ...
- Windows color
设置默认的控制台前景和背景颜色. COLOR [attr] attr 指定控制台输出的颜色属性. 颜色属性由两个十六进制数字指定 -- 第一个对应于背景,第二个对应于前景.每个数字可以为 ...