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