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;

namespace contest10
{
    class Program
    {
        static void Main(string[] args)
        {
            var read_line_origin = Console.ReadLine();

            if (string.IsNullOrEmpty(read_line_origin))
            {
                return;
            }

            //三角形の数
            int all_num = int.Parse(read_line_origin);

            
            //空白で分割する

            for (int i = 0; i < all_num; i++)
            {
                read_line_origin = Console.ReadLine();
                string[] words = read_line_origin.Split();

                //配列の要素、すべてに処理を行う
                var num_array = Array.ConvertAll(words, len => double.Parse(len));

                //三角形の座標
                double x1 = num_array[0];
                double y1 = num_array[1];
                double x2 = num_array[2];
                double y2 = num_array[3];
                double x3 = num_array[4];
                double y3 = num_array[5];

                //辺の長さ
                double r1 = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
                double r2 = Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
                double r3 = Math.Sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));

                //計算用
//                double tmp_1 = (r1 * r1) * (r2 * r2 + r3 * r3 - r1 * r1);
//                double tmp_2 = (r2 * r2) * (r3 * r3 + r1 * r1 - r2 * r2);
//                double tmp_3 = (r3 * r3) * (r1 * r1 + r2 * r2 - r3 * r3);

//                double tri_tmp = tmp_1 + tmp_2 + tmp_3;

  //              double center_x = (tmp_1 * x1 + tmp_2 * x2 + tmp_3 * x3) / tri_tmp;
  //              double center_y = (tmp_1 * y1 + tmp_2 * y2 + tmp_3 * y3) / tri_tmp;

                double x = (((x1 * x1 + y1 * y1) * (y2 - y3)) +
                            ((x2 * x2 + y2 * y2) * (y3 - y1)) +
                            ((x3 * x3 + y3 * y3) * (y1 - y2)))
                            /
                            ((x1 * (y2 - y3)) +
                             (x2 * (y3 - y1)) +
                             (x3 * (y1 - y2))
                            ) * 0.5;
                double y = (((x1 * x1 + y1 * y1) * (x2 - x3)) + ((x2 * x2 + y2 * y2) * (x3 - x1)) + ((x3 * x3 + y3 * y3) * (x1 - x2))) / ((y1 * (x2 - x3)) + (y2 * (x3 - x1)) + (y3 * (x1 - x2))) * 0.5;


                double radius = (r1 * r2 * r3) /
                                Math.Sqrt(
                                    (r1 + r2 + r3) * (-r1 + r2 + r3) * (r1 - r2 + r3) * (r1 + r2 - r3)

                                );

                Console.WriteLine("{0:f3} {1:f3} {2:f3}", x, y, radius);
            }




        }
    }
}