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)


//class Program
//{
//    static void Main()
//    {
//        double a = int.Parse(System.Console.In.ReadLine());
//        double b = 10;
//        double v = a*b/a;
//        System.Console.WriteLine(v);

//    }
//}

//using System;

//class Program
//{
//    static void Main()
//    {
//        Triangle saNkaku = new Triangle();
//        const int TRIAXIS = 6;
//        const int TRIANGLE = 3;
//        string[] line = new string[TRIAXIS];
//        double[] axis = new double[TRIAXIS];
//        double[] side = new double[TRIANGLE];
//        double centrx;
//        double centry;
//        int times = int.Parse(Console.ReadLine());
//        for (int i = 0; i < times; ++i)
//        {
//            line = Console.ReadLine().Split();
//            for (int j = 0; j < line.Length; ++j)
//            {
//                ///even axises are for x
//                axis[j] = double.Parse(line[j]);
//            }
//            side[0] = saNkaku.mkside(axis[0], axis[1], axis[2], axis[3]);
//            side[1] = saNkaku.mkside(axis[0], axis[1], axis[4], axis[5]);
//            side[2] = saNkaku.mkside(axis[2], axis[3], axis[4], axis[5]);
//            if (axis[0] == 0 && axis[1] == 0)
//            {
//                centrx = (axis[0] + axis[2] + axis[4]) / 6;
//                centry = (axis[1] + axis[3] + axis[5]) / 6;
//            }
//            else if (axis[0] == 0)
//            {
//                centrx = (axis[0] + axis[2] + axis[4]) / 6;
//                centry = (axis[1] + axis[3] + axis[5]) / (axis[1] * 6);
//            }
//            else if (axis[1] == 0)
//            {
//                centrx = (axis[0] + axis[2] + axis[4]) / (axis[0] * 6);
//                centry = (axis[1] + axis[3] + axis[5]) / 6;
//            }
//            else
//            {
//                centrx = (axis[0] + axis[2] + axis[4]) / (axis[0] * 6);
//                centry = (axis[1] + axis[3] + axis[5]) / (axis[1] * 6);
//            }
//            double Sq = saNkaku.Heron(side[0], side[1], side[2]);
//            double sides = side[0] * side[1] * side[2];
//            double rad = saNkaku.mkrad(sides, Sq);
//            // double CircX = saNkaku.mkcent(axis[0],centrx);
//            // double CircY = saNkaku.mkcent(axis[1],centry);
//            Console.WriteLine("{0:f3} {1:f3} {2:f3}", centrx, centry, rad);
//        }
//    }
//}
//class Triangle
//{
//    internal double mkside(double leftX, double leftY, double rightX, double rightY)
//    {
//        double x = Math.Abs(rightX - leftX);
//        double y = Math.Abs(rightY - leftY);
//        return Math.Sqrt(x * x + y * y);
//    }
//    internal double Heron(double a, double b, double c)
//    {
//        double s = (a + b + c) / 2;
//        return s * (s - a) * (s - b) * (s - c);
//    }
//    internal double mkrad(double abc, double S)
//    {
//        return abc / (2 * S);
//    }
//    internal double mkcent(double start, double centrsum)
//    {
//        return centrsum / 2;
//    }
//}

using System;

class Program
{
    static void Main()
    {
        Triangle tri = new Triangle();
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            double x1 = double.Parse(s1[0]);
            double y1 = double.Parse(s1[1]);
            double x2 = double.Parse(s1[2]);
            double y2 = double.Parse(s1[3]);
            double x3 = double.Parse(s1[4]);
            double y3 = double.Parse(s1[5]);
            double x12 = x1 - x2;
            double y12 = y1 - y2;
            double x23 = x2 - x3;
            double y23 = y2 - y3;
            double x31 = x3 - x1;
            double y31 = y3 - y1;
            double a = tri.MkSide(x12, y12);
            double b = tri.MkSide(x23, y23);
            double c = tri.MkSide(x31, y31);
            double r = tri.Mkradius(a, b, c);
            double x = (((tri.side(x1,y1,y23)) + (tri.side(x2,y2,y31)) + (tri.side(x3,y3,y12))) / ((x1 * y23) + (x2 * y31) + (x3 * y12))) / 2;
            double y = (((tri.side(x1,y1,x23)) + (tri.side(x2,y2,x31)) + (tri.side(x3,y3,x12))) / ((y1 * x23) + (y2 * x31) + (y3 * x12))) / 2;
            Console.WriteLine("{0:F3} {1:F3} {2:F3}", x, y, r);
        }
    }
}
class Triangle
{
    internal double MkSide(double x, double y)
    {
        return Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
    }
    internal double Mkradius(double a, double b, double c)
    {
        return (a * b * c) / Math.Sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
    }
    internal double side(double x, double y, double side1)
    {
        return (Math.Pow(x, 2) + Math.Pow(y, 2)) * side1;
    }
}