Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TwoOperations {
  4. public static void main(String[] args) {
  5. Scanner in=new Scanner(System.in);
  6. int tc=in.nextInt();
  7. for (int t = 0; t <tc ; t++) {
  8. double r1=in.nextDouble(),r2=in.nextDouble();
  9. double triArea=((r1+r2)*r1)/2.0;
  10. double xx=Math.sqrt(r1*r1+(r1+r2)*(r1+r2));
  11. // double a=Math.asin(r1/xx);
  12. double a=Math.toDegrees(Math.atan(r1/(r1+r2)));
  13. double b=180-(90+a);
  14. double arc1=Math.PI*r2*r2*(a/360.0);
  15. double g=180-2*b;
  16. double L=2*r1*Math.toDegrees(Math.sin(Math.toRadians(g/2.0)));
  17. double d=Math.sqrt(-(L/2.0)*(L/2.0)+r1*r1);
  18. double h = Math.sin(Math.toRadians(g)) * r1;
  19. double arc2=(r1*h)/2.0;
  20. double arc3=Math.PI*r1*r1*((90-g)/360.0);
  21.  
  22.  
  23. double ans=triArea-(arc1+arc2+arc3);
  24. System.out.printf("%.9f\n",ans);
  25.  
  26.  
  27.  
  28.  
  29. }//fortc
  30. }//psvm
  31. }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement