P5951
panyanppyy · · 题解
写题解是因为另一篇有误。
Problem
有个水缸,里面东西都不会碰撞,放入
Solution
显然,这是一道初中物理题。
对物体分类讨论:
-
-
$\because F_\texttt浮=\rho_\texttt水\cdot g\cdot V_\texttt{排} 又
\because F_\texttt{浮}=G=l_i^3\cdot\rho_i\cdot g \therefore V_\texttt{排}=\dfrac{l_i^3\cdot\rho_i}{\rho_\texttt{水}} \therefore$ 水面上升 $\dfrac{V_\texttt{排}}{s}
小剪枝:当高度超过
Code
#include<bits/stdc++.h>
using namespace std;
double ans,l,p;
int n,s,h,v;
int main(){
scanf("%d%d%d%d",&s,&h,&v,&n),ans=1.*v/s;
for(int i=1;i<=n;i++){
scanf("%lf%lf",&l,&p);
if(p>=1)ans+=l*l*l/s;
else ans+=l*l*l*p/s;
if(ans>=h)return printf("%d",h),0;
}
printf("%.7f",ans);
return 0;
}