First, we can find the circle radius, and then use two formulas to solve the equations.
A * B = | a | * | B | * cos (120 );
X * x + y * y = r * r;
There are exactly two solutions for solving the equation, and they are for the sake.
The Code is as follows:
Here is a circle with a radius of r. The circle center is located at the origin, let you find that the two points on the circle are the maximum distance between the two points and the given point. Obviously, they are the maximum distance between each other at 120 degrees. # Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <vector> # include <list> # include <deque> # include <queue> # include <iterator> # include <stack> # include <map> # include <set> # include <algorithm> # include <cctype> using namespace std; typedef long LL; const int N = 21; const ll ii = 1000000007; double x, y, r, r2; double xx0, yy0, xx1, yy1; int main () {int T; cin> T; while (T --) {scanf ("% lf", & x, & y ); r2 = (x * x + y * y); double a, B, c; a = r2; B = r2 * y; c = r2 * r2/4-x * x * r2; yy0 = (-B-sqrt (B * B-4 * a * c)/2/; yy1 = (-B + sqrt (B * B-4 * a * c)/2/; /*/This place to solve x can not use x * x + y * y = r2 to calculate, should not know the positive and negative number xx0 = sqrt (r2-yy0 * yy0 ); xx1 = sqrt (r2-yy1 * yy1); */if (fabs (x-0) <1e-7) {xx0 =-sqrt (r2-yy0 * yy0 ); xx1 = sqrt (r2-yy1 * yy1);} else {xx0 = (-r2/2-yy0 * y)/x; xx1 = (-r2/2-yy1 * y)/x ;} printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n ", xx0, yy0, xx1, yy1);} return 0 ;}