Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TwoOperations {
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- int tc=in.nextInt();
- for (int t = 0; t <tc ; t++) {
- double r1=in.nextDouble(),r2=in.nextDouble();
- double triArea=((r1+r2)*r1)/2.0;
- double xx=Math.sqrt(r1*r1+(r1+r2)*(r1+r2));
- // double a=Math.asin(r1/xx);
- double a=Math.toDegrees(Math.atan(r1/(r1+r2)));
- double b=180-(90+a);
- double arc1=Math.PI*r2*r2*(a/360.0);
- double g=180-2*b;
- double L=2*r1*Math.toDegrees(Math.sin(Math.toRadians(g/2.0)));
- double d=Math.sqrt(-(L/2.0)*(L/2.0)+r1*r1);
- double h = Math.sin(Math.toRadians(g)) * r1;
- double arc2=(r1*h)/2.0;
- double arc3=Math.PI*r1*r1*((90-g)/360.0);
- double ans=triArea-(arc1+arc2+arc3);
- System.out.printf("%.9f\n",ans);
- }//fortc
- }//psvm
- }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement