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 JAVA (judge verdict: Accepted)

import java.io.*;

public class Main{
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int lineNum = Integer.parseInt(br.readLine());
		for(int i=0; i<lineNum; i++){
			line = br.readLine();
			String[] sCoord = line.split(" ");
			float[] fCoord = new float[6];
			for(int j=0; j<6; j++){
				fCoord[j] = Float.parseFloat(sCoord[j]);
			}
			/*
			 * 違う
			 * float cenX = (fCoord[0] + fCoord[2] + fCoord[4])/3.0f;
			 * float cenY = (fCoord[1] + fCoord[3] + fCoord[5])/3.0f;
			 */
			
			float div = (fCoord[0]-fCoord[2])*(fCoord[3]-fCoord[5])-(fCoord[2]-fCoord[4])*(fCoord[1]-fCoord[3]);
			float n = fCoord[0]*fCoord[0] - fCoord[2]*fCoord[2] + fCoord[1]*fCoord[1] - fCoord[3]*fCoord[3];
			float m = fCoord[2]*fCoord[2] - fCoord[4]*fCoord[4] + fCoord[3]*fCoord[3] - fCoord[5]*fCoord[5];
			float a = fCoord[3]-fCoord[5];
			float b = fCoord[3]-fCoord[1];
			float c = fCoord[4]-fCoord[2];
			float d = fCoord[0]-fCoord[2];
			float cenX = (a*n + b*m)/div/2;
			float cenY = (c*n + d*m)/div/2;
			if(cenX == 0.0)cenX=0.0f;
			if(cenY == 0.0)cenY=0.0f;
			float dis = (float)Math.sqrt(Math.pow((double)cenX-fCoord[0], 2.0) + Math.pow((double)cenY-fCoord[1], 2.0));
			System.out.printf("%.3f %.3f %.3f\n", cenX, cenY, dis);
		}
	}
}