【lightoj1331】Agent J【计算几何】

你的名字 2022-07-17 01:43 129阅读 0赞

F - F 圆周率用acos(-1.0) 使用longlong

Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu

Submit Status Practice LightOJ 1331 12x12_uDebug.pnguDebug

Description

Agent J is preparing to steal an antique diamond piece from a museum. As it is fully guarded and they are guarding it using high technologies, it’s not easy to steal the piece. There are three circular laser scanners in the museum which are the main headache for Agent J. The scanners are centered in a certain position, and they keep rotating maintaining a certain radius. And they are placed such that their coverage areas touch each other as shown in the picture below:

ab59e480141d7b84bb2c38efc0f7f6fa

Here R1, R2 and R3 are the radii of the coverage areas of the three laser scanners. The diamond is placed in the place blue shaded region as in the picture. Now your task is to find the area of this region for Agent J, as he needs to know where he should land to steal the diamond.

Input

Input starts with an integer T (≤ 1000), denoting the number of test cases.

Each case starts with a line containing three real numbers denoting R1, R2 and R3 (0 < R1, R2, R3 ≤ 100). And no number contains more than two digits after the decimal point.

Output

For each case, print the case number and the area of the place where the diamond piece is located. Error less than10-6 will be ignored.

Sample Input

3

1.0 1.0 1.0

2 2 2

3 3 3

Sample Output

Case 1: 0.16125448

Case 2: 0.645017923

Case 3: 1.4512903270

只要注意细节别弄错精度上一般没问题,先用余弦定理求出每个圆对应的圆心角,然后就能求出该圆心角对应的扇形面积,用总面积减去各扇形面积就行了。

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<algorithm>
  6. #define PI acos(-1.0)
  7. using namespace std;
  8. double find(double a,double b,double c){
  9. return acos((b*b+a*a-c*c)/(2*a*b));
  10. }
  11. double cocu(double x,double r){
  12. return x*r*r/2;
  13. }
  14. int main() {
  15. int T,p=0;
  16. scanf("%d",&T);
  17. while(T--) {
  18. double r1,r2,r3;
  19. scanf("%lf%lf%lf",&r1,&r2,&r3);
  20. double w1,w2,w3;
  21. w1=find(r1+r2,r1+r3,r2+r3);
  22. w2=find(r1+r2,r2+r3,r1+r3);
  23. w3=find(r3+r1,r3+r2,r1+r2);
  24. // printf("%lf %lf %lf--\n",w1,w2,w3);
  25. double s1,s2,s3,s;
  26. s1=cocu(w1,r1);
  27. s2=cocu(w2,r2);
  28. s3=cocu(w3,r3);
  29. // printf("%lf %lf %lf==\n",s1,s2,s3);
  30. s=(r1+r2)*(r2+r3)*sin(w2)/2.0;
  31. printf("Case %d: %lf\n",++p,s-s1-s2-s3);
  32. }
  33. return 0;
  34. }

发表评论

表情:
评论列表 (有 0 条评论,129人围观)

还没有评论,来说两句吧...

相关阅读

    相关 计算几何

    平面上有有条线段,判断这两条线段是否会相交。 【line.in】 0 0 1 1 0 1 1 0 【line.out】 1 判断线段相交可以用跨立实验+快速排斥