eolymp
bolt
Try our new interface for solving problems
Problems

Circle through three points

Circle through three points

Three points are given on the plane that do not lie on one line. Find the equation of the circle that passes through them. Print the solution in the form $$ (x - a)^2 + (y - b)^2 = r^2~~~(1) $$ and $$ x^2 + y^2 + cx + dy + e = 0~~~(2) $$ \InputFile Each line contains six real numbers $A_x, A_y, B_x, B_y, C_x, C_y$ --- the coordinates of three points $A~(A_x, A_y)$, $B~(B_x, B_y)$, $C~(C_x, C_y)$. \OutputFile For each test case print the equation of a circle in two formats as given in a sample. The values of $h, k, r, c, d$ and $e$ in Equations 1 and 2 are to be printed with three decimal digits. If some of $h, k, c, d, e$ is zero, do not print the corresponding term. Plus and minus signs in the equations should be changed as needed to avoid multiple signs before a number. Plus, minus, and equal signs must be separated from the adjacent characters by a single space on each side. No other spaces are to appear in the equations. Print a single blank line after each equation pair. See output format in example.
Time limit 1 second
Memory limit 128 MiB
Input example #1
7.0 -5.0 -1.0 1.0 0.0 -6.0
2.0 2.0 0.0 4.0 -2.0 2.0
Output example #1
(x - 3.000)^2 + (y + 2.000)^2 = 5.000^2
x^2 + y^2 - 6.000x + 4.000y - 12.000 = 0

x^2 + (y - 2.000)^2 = 2.000^2
x^2 + y^2 - 4.000y = 0