fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main
  5. {
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8. PrintWriter out = new PrintWriter(System.out);
  9.  
  10. short N = in.nextShort();
  11. double r, d, h_1, a, b;
  12. for (int i = 1; i <= N; i++){
  13. r = in.nextDouble();
  14. d = in.nextDouble();
  15. h_1 = in.nextDouble();
  16. out.print("Case " + i + ": ");
  17. a = Math.asin((r - h_1) / r) - Math.asin((r - d) / r);
  18. if (a == 0){
  19. out.format("%.4f%n", h_1);
  20. }
  21. else{
  22. b = 2 * Math.sqrt(r*r - (r - d) * (r - d)) + h_1 / Math.sin(a);
  23. out.format("%.4f%n", b * Math.sin(a));
  24. }
  25. }
  26.  
  27. out.flush();
  28. }
  29. }
Success #stdin #stdout 0.14s 2184192KB
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