LightOJ 1433-Minimum Arc Distance【几何】

亦凉 2022-08-21 13:39 104阅读 0赞

1433 - Minimum Arc Distance










    PDF (English) Statistics Forum







Time Limit: 2 second(s) Memory Limit: 32 MB

You all probably know how to calculate the distance between two points in two dimensional cartesian plane. But in this problem you have to find the minimum arc distance between two points and they are on a circle centered at another point.

You will be given the co-ordinates of the points A and B and co-ordinate of the center O. You just have to calculate the minimum arc distance between A and B. In the picture, you have to calculate the length of arc ACB. You can assume that A and B will always be on the circle centered at O.

a.png

Input

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

Each case starts with a line containing six integers Ox, Oy, Ax, Ay, Bx, By where (Ox, Oy) indicates the co-ordinate of O, (Ax, Ay) denote the co-ordinate of A and (Bx, By) denote the co-ordinate of B. All the integers will lie in the range [1, 10000].

Output

For each case, print the case number and the minimum arc distance. Errors less than 10-3 will be ignored.












Sample Input

Output for Sample Input

5

5711 3044 477 2186 3257 7746

3233 31 3336 1489 1775 134

453 4480 1137 6678 2395 5716

8757 2995 4807 8660 2294 5429

4439 4272 1366 8741 6820 9145

Case 1: 6641.81699183

Case 2: 2295.92880

Case 3: 1616.690325

Case 4: 4155.64159340

Case 5: 5732.01250253


PROBLEM SETTER: ARIF SIDDIQUEE

SPECIAL THANKS: JANE ALAM JAN

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<cmath>
  4. #include<algorithm>
  5. using namespace std;
  6. int main()
  7. {
  8. int t,tt=0;
  9. scanf("%d",&t);
  10. while(t--)
  11. {
  12. double ox,oy,x1,y1,x2,y2;
  13. scanf("%lf%lf%lf%lf%lf%lf",&ox,&oy,&x1,&y1,&x2,&y2);
  14. printf("Case %d: ",++tt);
  15. double l1,l2;
  16. l1=sqrt((ox-x1)*(ox-x1)+(oy-y1)*(oy-y1));
  17. l2=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  18. l2=(double)l2/2;
  19. double a=asin(l2/l1);
  20. a=a*2.0;
  21. printf("%.10lf\n",a*l1);
  22. }
  23. return 0;
  24. }

发表评论

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

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

相关阅读

    相关 arc

    提示:本文中所说的"实例变量"即是"成员变量","局部变量"即是"本地变量" 一、简介 ARC是自iOS 5之后增加的新特性,完全消除了手动管理内存的烦