Advertisement
Anik_Akash

loght oj 1433 - Minimum Arc Distance

Jun 29th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. //thanks God For Every Thing!
  2. //contest link:http://www.lightoj.com/volume_showproblem.php?problem=1433
  3. //#include<bits/stdc++.h>
  4. #include<stdio.h>
  5. #include<math.h>
  6. #define pi                      acose(-1)
  7. #define rep(i,x)                for(int i=0; i<(x); i++)
  8. #define rep1(i,x)               for(int i=1; i<=(x); i++)
  9.  
  10. typedef long long int           ll;
  11. typedef double                  dl;
  12. //using namespace std;
  13.  
  14. int main()
  15. {
  16.     int t;
  17.     scanf("%d", &t);
  18.     rep1(i,t)
  19.     {
  20.         int  ox, oy, ax, ay, bx, by;
  21.         scanf("%d %d %d %d %d %d", &ox, &oy, &ax, &ay, &bx, &by);
  22.         dl A,C,B;
  23.         A = sqrt(((ox-ax)*(ox-ax))+((oy-ay)*(oy-ay)));
  24.         //B = sqrt(((ox-bx)*(ox-bx))+((oy-by)*(oy-by))); cause A = B; so find any one is okay;
  25.         C = sqrt(((bx-ax)*(bx-ax))+((by-ay)*(by-ay)));
  26.  
  27.         dl ang, ans;
  28.         ang = acos(((A*A)+(A*A)-(C*C))/(2.0*A*A)); // law of  cosine;
  29.  
  30.         ans = A*ang; // s = r * theta; formula;
  31.  
  32.  
  33.         printf("Case %d: %lf\n", i, ans);
  34.     }
  35.     return 0;
  36. }
  37. //author: ANIKAKSH;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement