题目传送
二分半径比体积
没啥好说的,主要是这个体积公式
圆台体积公式:
π * h * ( r *r + R * R + R *r)/3
水当高度为x时,上底半径为:
(R - r) * x / H + r
上下底半径差占高度的几份,再加上最小半径
AC代码
#include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
#define int long long
const int N = 3e6 + 100;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-5;
const int mod = 1e9+7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
double r,R,H,V;
double check(double x)
{
double u = (R-r)*x/H + r;
double sum = II*x*(r*r+u*u+r*u)/3;
return sum;
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int t;
cin >> t;
while(t--)
{
cin >> r >> R >> H >> V;
double ll = 0,rr = H;
while(rr - ll >= 1e-9)
{
double mid = (ll+rr)/2;
if(check(mid) > V)
rr = mid;
else
ll = mid;
}
cout << fixed << setprecision(6) << ll << endl;
}
}