Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void solve(int t) {
- int r1, r2, h, p; cin >> r1 >> r2 >> h >> p;
- double r = r1 - ((r1 - r2) / h * (h - p));
- double x = (r1 * h) / (r1 - r2);
- double ans = (acos(-1) / 3) * ((r * r * (x - h + p)) - (r2 * r2 * (x - h)));
- printf("Case %d: %0.9f\n", t, ans);
- }
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int T = 1; cin >> T;
- for (int i = 1; i <= T; i++) {
- solve(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement