fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. unsigned short N;
  8. double r, d, h_1, a, b;
  9. cin >> N;
  10. for (int i = 1; i <= N; i++) {
  11. cin >> r >> d >> h_1;
  12. cout << "Case " << i << ": ";
  13. a = asin((r - h_1) / r) - asin((r - d) / r);
  14. if (a == 0)
  15. cout << fixed << setprecision(4) << h_1 << endl;
  16. else{
  17. b = 2 * sqrt(r * r - (r - d) * (r - d)) + h_1 / sin(a);
  18. cout << fixed << setprecision(4) << b * sin(a) << endl;
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
5
94 21 12
23 9 8
5 4 3
2 2 1
43 26 20
stdout
Case 1: 32.1226
Case 2: 10.0439
Case 3: 5.0440
Case 4: 3.0000
Case 5: 32.4231