Go: package main

import (
	"fmt"
	"math"
)

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		circleTriangle()
	}
}

func scanInt() int {
	var n int
	fmt.Scanf("%d", &n)
	return n
}

func circleTriangle() {
	var x1, y1, x2, y2, x3, y3 float64
	fmt.Scanf("%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3)
	a := 2 * (x1 - x2)
	b := 2 * (y1 - y2)
	c := 2 * (x1 - x3)
	d := 2 * (y1 - y3)
	e := x1*x1 - x2*x2 + y1*y1 - y2*y2
	f := x1*x1 - x3*x3 + y1*y1 - y3*y3

	px := (d*e - b*f) / (a*d - b*c)
	py := (a*f - c*e) / (a*d - b*c)

	r := math.Sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py))
	fmt.Printf("%.3f %.3f %.3f\n", px, py, r)
}

Python: # Circumscribed Circle of a Triangle
import math
def simul_eq(a,b,c,d,e,f):
    # A = [[a,b],[d,e]]
    C = [c,f]
    detA = a*e - b*d
    # if detA == 0: raise # det(A) == 0.
    At = [[e,-b],[-d,a]]
    x = sum(map((lambda x,y: x*y), At[0], C)) / detA
    y = sum(map((lambda x,y: x*y), At[1], C)) / detA
    fx,fy = '{0:.3f}'.format(x), '{0:.3f}'.format(y)
    if fx == '-0.000': fx = fx[1:]
    if fy == '-0.000': fy = fy[1:]
    return (fx,fy)

n = int(input())
for _ in range(n):
    x1,y1,x2,y2,x3,y3 = map(float, input().split())
    a = math.sqrt(pow(x2-x3, 2) + pow(y2-y3, 2))
    b = math.sqrt(pow(x1-x3, 2) + pow(y1-y3, 2))
    c = math.sqrt(pow(x2-x1, 2) + pow(y2-y1, 2))
    cosA = (pow(b,2) + pow(c,2) - pow(a,2)) / (2*b*c)
    sinA = math.sqrt(1 - pow(cosA,2))
    R = a / (2 * sinA)
    cen = simul_eq(x2-x1, y2-y1, (y2**2 - y1**2 + x2**2 - x1**2) / 2, x3-x1, y3-y1, (y3**2 - y1**2 + x3**2 - x1**2) / 2)
    print(' '.join(cen), '{0:.3f}'.format(R))

Python: import math

def da(li):
    x1,y1,x2,y2,x3,y3=[float(i) for i in li]
    xp,yp=(x2-x1)/2,(y2-y1)/2
    xq,yq=(x3-x1)/2,(y3-x1)/2
    t=(xq**2+yq**2-xp*xq-yp*yq)/(xp*yq-xq*yp)
    return xp-t*yp,yp+t*xp
def sis(fl):
    fls=str(fl)
    if len(fls)<6:return fls+"".join(["0" for i in range(5-len(fls))])
    if int(fls[5:6])>4:
        return fls[:4]+str(int(fls[4:5])+1)
    else:
        return fls[:5]

n=int(input())
for i in range(n):
    li=input().split(" ")
    x,y=da(li)
    print(sis(x)+" "+sis(y)+" "+sis(math.sqrt(x**2+y**2)))

Python: import math

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())

    s = 0.5*((x1-x3)*(y2-y3) - (x2-x3)*(y1-y3))
    a = (x2-x3)**2 + (y2-y3)**2
    b = (x1-x3)**2 + (y1-y3)**2
    c = (x2-x1)**2 + (y2-y1)**2

    rx = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3)/(16*s**2)
    ry = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3)/(16*s**2)
    r = math.sqrt((rx-x1)**2 + (ry-y1)**2)
    print( "{0:.3f} {1:.3f} {2:.3f}".format(rx+0, ry+0, r+0))

Python: import math

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
    a2 = y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2
    px = ((y1 - y3) * a1 - (y1 - y2) * a2) / (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3))
    py = ((x1 - x3) * a1 - (x1 - x2) * a2) / (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3))
    r = math.sqrt(px ** 2 + py ** 2)
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Python: # Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def circumscribed_circle(x1, y1, x2, y2, x3, y3):
    d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
    px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
    py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
    a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
    s = (a + b + c) / 2
    A = math.sqrt(s * (s - a) * (s - b) * (s - c))
    r = a * b * c / (4 * A)
    return px, py, r

          
N = int(input())
for k in range(N):
    x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
    px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
    print("%.3f %.3f %.3f" % (px, py, r))

Python: import math
n=int(raw_input())
for i in range(n):
    x1,y1,x2,y2,x3,y3=[float(i) for i in raw_input().split()]
    t1=x1*(x2+x3-x1)+y1*(y2+y3-y1)
    t2=x2*(x1+x3-x2)+y2*(y1+y3-y2)
    t3=x3*(x1+x2-x3)+y3*(y1+y2-y3)
    px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3)
    py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3)
    r=math.hypot(px-x1,py-y1)
    print("{0} {1} {2}".format(round(px,3),round(py,3),round(r,3)))

Python: from math import hypot
n=int(input())
for i in range(n):
	x1,y1,x2,y2,x3,y3=map(int,input().split())
	x4=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
	y4=((x1-x3)*(x1**2-x2**2+y1**2-x1**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
	r=hypot(x1-x4,y1-y4)
	print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))

Python: import math
for _ in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
    q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))
    r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)
    print("{:.3f} {:.3f} {:.3f}".format(p, q, r))

Python: # coding=utf-8
import math


if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        x1, y1, x2, y2, x3, y3 = map(float, input().split())
        points_list = [[x1, y1], [x2, y2], [x3, y3]]
        points_list.sort()
        print(points_list)

        if points_list[0][0] == points_list[1][0]:
            py = (points_list[0][1] + points_list[1][1])/2
            a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
            a2 = -1/a2_s
            m13x = (points_list[0][0] + points_list[2][0])/2
            m13y = (points_list[0][1] + points_list[2][1])/2
            b2 = m13y - a2*m13x
            px = (py - b2)/a2
        elif points_list[1][0] == points_list[2][0]:
            py = (points_list[1][1] + points_list[2][1])/2
            a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
            a2 = -1/a2_s
            m13x = (points_list[0][0] + points_list[2][0])/2
            m13y = (points_list[0][1] + points_list[2][1])/2
            b2 = m13y - a2*m13x
            px = (py - b2)/a2
        else:
            a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
            a1 = -1/a1_s
            a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
            a2 = -1 / a2_s
            m12x = (points_list[0][0] + points_list[1][0]) / 2
            m12y = (points_list[0][1] + points_list[1][1]) / 2
            m13x = (points_list[0][0] + points_list[2][0]) / 2
            m13y = (points_list[0][1] + points_list[2][1]) / 2
            b1 = m12y - a1 * m12x
            b2 = m13y - a2 * m13x
            px = (b2 - b1)/(a1 - a2)
            py = a1*px + b1
        r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
        print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r))

Python: from decimal import Decimal
import math
for _ in range(int(input())):
    x1,y1,x2,y2,x3,y3=list(map(Decimal,input().split()))
    a=x1-x3
    b=y2-y3
    c=x2-x3
    d=y1-y3
    e=y1-y2
    f=x1+x3
    g=x2+x3
    X=(b*d*e+a*b*f-c*d*g)/2/(a*b-c*d)
    try:
        Y=-(a/d)*(X-f/2)+(y1+y3)/2
    except:
        Y=-(c/b)*(X-g/2)+(y2+y3)/2
    R=math.sqrt((x1-X)**2+(y1-Y)**2)
    print(" ".join(["{:.3f}".format(i) for i in [X,Y,R]]))