Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define PI 3.14159265
- #define inf -1000000007
- using namespace std;
- pair <double, double> s(double a, double b, double c)
- {
- double x1=0, x2=0, d=0;
- d=b*b-4*a*c;
- if(d<0)
- {
- return {inf, inf};
- }
- else
- {
- if(d==0)
- {
- x1=-b/(2*a);
- return {x1, inf};
- }
- else
- {
- x1=-b/(2*a)-(sqrt (d))/(2*a);
- x2=-b/(2*a)+(sqrt (d))/(2*a);
- return {x1, x2}
- }
- }
- }
- pair <double, double> eq(double x1, double y1, double x2, double y2)
- {
- double k = (abs(y2 - y1)) / ((abs(x2 - x1)));
- double b = y1 - k * x1;
- return {k, b};
- }
- pair <double, double> f(double r, double k, double b)
- {
- return s(k * k + 1, 2 * b * k, b * b - r * r);
- }
- int main()
- {
- int n;
- scanf("%d", &n);
- while (n--)
- {
- double x1, y1, x2, y2, r;
- cin >> x1 >> y1 >> x2 >> y2 >> r;
- pair <double, double> a = eq(x1, y1, x2, y2);
- pair <double, double> b = f(r, a.first, a.second);
- if ((b.first == inf && b.second == inf) || (b.first != inf && b.second == inf))
- cout << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
- else
- {
- double path;
- double angle = acos((2 * r * r - path * path) / (2 * r * r));
- angle = angle * 180 / PI;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement