Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define PI 3.14159265
  3. #define inf -1000000007
  4.  
  5. using namespace std;
  6.  
  7. pair <double, double> s(double a, double b, double c)
  8. {
  9. double x1=0, x2=0, d=0;
  10. d=b*b-4*a*c;
  11. if(d<0)
  12. {
  13. return {inf, inf};
  14. }
  15. else
  16. {
  17. if(d==0)
  18. {
  19. x1=-b/(2*a);
  20. return {x1, inf};
  21. }
  22. else
  23. {
  24.  
  25. x1=-b/(2*a)-(sqrt (d))/(2*a);
  26. x2=-b/(2*a)+(sqrt (d))/(2*a);
  27. return {x1, x2}
  28. }
  29. }
  30.  
  31. }
  32.  
  33. pair <double, double> eq(double x1, double y1, double x2, double y2)
  34. {
  35. double k = (abs(y2 - y1)) / ((abs(x2 - x1)));
  36. double b = y1 - k * x1;
  37.  
  38. return {k, b};
  39. }
  40.  
  41. pair <double, double> f(double r, double k, double b)
  42. {
  43. return s(k * k + 1, 2 * b * k, b * b - r * r);
  44. }
  45.  
  46. int main()
  47. {
  48. int n;
  49. scanf("%d", &n);
  50.  
  51. while (n--)
  52. {
  53. double x1, y1, x2, y2, r;
  54. cin >> x1 >> y1 >> x2 >> y2 >> r;
  55.  
  56. pair <double, double> a = eq(x1, y1, x2, y2);
  57. pair <double, double> b = f(r, a.first, a.second);
  58.  
  59. if ((b.first == inf && b.second == inf) || (b.first != inf && b.second == inf))
  60. cout << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  61. else
  62. {
  63. double path;
  64. double angle = acos((2 * r * r - path * path) / (2 * r * r));
  65. angle = angle * 180 / PI;
  66. }
  67. }
  68.  
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement