-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path1549.cpp
30 lines (30 loc) · 849 Bytes
/
1549.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Ivan Carvalho
// Solution to https://www.beecrowd.com.br/judge/problems/view/1549
#include <cmath>
#include <cstdio>
const double PI = acos(-1.0);
const double EPS = 1e-4;
int main() {
int TC;
scanf("%d", &TC);
while (TC--) {
int n, cap;
double ini, fim, meio, resp, r, R, altura;
scanf("%d %d", &n, &cap);
scanf("%lf %lf %lf", &r, &R, &altura);
ini = 0.0;
fim = altura;
while (fim - ini > EPS) {
meio = (ini + fim) * 0.5;
double B = r + ((R - r) / altura) * meio;
double volume = PI * meio * (B * B + B * r + r * r) / 3.0;
if (n * volume >= cap) {
resp = meio;
fim = meio - EPS;
} else
ini = meio + EPS;
}
printf("%.2lf\n", resp);
}
return 0;
}