Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Circumscribed Circle of A Triangle.

Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.

Input

Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:

$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$

in a line. All the input are real numbers.

Output

For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.

Constraints

$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$

$ n \leq 20$

Sample Input

1
0.0 0.0 2.0 0.0 2.0 2.0

Output for the Sample Input

1.000 1.000 1.414

Solution in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0010
{
    class Program
    {
        static double _radius = 0;
        static double[] _threePoints = new double[6];
        static double[] _centerPoint = new double[2];
        static double _x_CenterPoint = 0;
        static double _y_CenterPoint = 0;

        static void Main(string[] args)
        {
            int NumOfSumple = int.Parse(Console.ReadLine());
            for (int i = 0; i < NumOfSumple; ++i)
            {
                _threePoints = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                _centerPoint = Calculation.EvaluateCenterOfCircleFrom3Points(_threePoints);
                _x_CenterPoint = _centerPoint[0];
                _y_CenterPoint = _centerPoint[1];
                _radius = Calculation.EvaluateRadiusFrom3Points(_threePoints, _centerPoint);
                Console.WriteLine(_x_CenterPoint.ToString("F3") + " " + _y_CenterPoint.ToString("F3") + " " + _radius.ToString("F3"));
            }
        }

    }
    class Calculation
    {
        internal static double[] EvaluateCenterOfCircleFrom3Points(double[] threePoints)
        {
            double[] centerPoint = new double[2];
            double x_Circle = centerPoint[0];
            double y_Circle = centerPoint[1];
            double x1 = threePoints[0];
            double y1 = threePoints[1];
            double x2 = threePoints[2];
            double y2 = threePoints[3];
            double x3 = threePoints[4];
            double y3 = threePoints[5];

            x_Circle = ((y3 - y2) * (Math.Pow(x1, 2) + Math.Pow(y1, 2)) - ((y3 - y1) * (Math.Pow(x2, 2) + Math.Pow(y2, 2))) - ((y1 - y2) * (Math.Pow(x3, 2) + Math.Pow(y3, 2))))
                           / (2 * ((y3 - y2) * (x1 - x2) - (y1 - y2) * (x3 - x2)));
            y_Circle = (-(x3 - x1) * (Math.Pow(x2, 2) + Math.Pow(y2, 2)) + ((x3 - x2) * (Math.Pow(x1, 2) + Math.Pow(y1, 2))) - ((x1 - x2) * (Math.Pow(x3, 2) + Math.Pow(y3, 2))))
                           / (2 * ((x3 - x2) * (y1 - y2) - (x1 - x2) * (y3 - y2)));
            centerPoint[0] = x_Circle;
            centerPoint[1] = y_Circle;
            return centerPoint;
        }
        internal static double EvaluateRadiusFrom3Points(double[] threePoints, double[] centerPoint)
        {
            double radius = 0;
            double x1 = threePoints[0];
            double y1 = threePoints[1];
            double x_Center = centerPoint[0];
            double y_Center = centerPoint[1];

            radius = Math.Abs(Math.Sqrt(Math.Pow(x1 - x_Center, 2) + Math.Pow(y1 - y_Center, 2)));
            return radius;
        }
    }
}