Advertisement
coderbodrul

Untitled

Mar 3rd, 2024
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void solve(int t) {
  6.     int r1, r2, h, p; cin >> r1 >> r2 >> h >> p;
  7.     double r = r1 - ((r1 - r2) / h * (h - p));
  8.     double x = (r1 * h) / (r1 - r2);
  9.  
  10.     double ans = (acos(-1) / 3) * ((r * r * (x - h + p)) - (r2 * r2 * (x - h)));
  11.     printf("Case %d: %0.9f\n", t, ans);
  12.  
  13. }
  14.  
  15. int32_t main() {
  16.     ios_base::sync_with_stdio(0);
  17.     cin.tie(0);
  18.     int T = 1; cin >> T;
  19.     for (int i = 1; i <= T; i++) {
  20.         solve(i);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement