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



Sample input:
1
0.0 0.0 2.0 0.0 2.0 2.0


Sample output:
1.000 1.000 1.414

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import cmath

class Point(object):
    def __init__(self, x, y):
        self.point = complex(x, y)
    def __str__(self):
        return "x = {0}, y = {1}".format(self.point.real, self.point.imag)

class Triangle(Point):
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c

        self.edgeA = abs(b.point-c.point)
        self.edgeB = abs(c.point-a.point)
        self.edgeC = abs(a.point-b.point)

        self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
        self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
        self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)


    def angle(A, B, C):
        return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )



    def circumscribedCircleRadius(self):
        return abs((self.edgeA/cmath.sin(self.angleA))/2)


    def circumscribedCircleCenter(self):
        A = cmath.sin(2*self.angleA)
        B = cmath.sin(2*self.angleB)
        C = cmath.sin(2*self.angleC)
        X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
        Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
        return complex(X, Y)

line = list(map(float, input().split()))
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
T = Triangle(p1, p2, p3)
center = T.circumscribedCircleCenter()
print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius()))

Submission status: Runtime Error

Solution code:
# coding: UTF-8
# main.py
import math

t = map(int,raw_input().split())
for i in xrange(0,t[0]):
	x1,x2,x3,y1,y2,y3 = map(float,raw_input().split())
	a = x1-x2
	b = y1-y2
	c = -(x1*x1 + y1*y1 - x2*x2 - y2*y2)
	d = x2-x3
	e = y2-y3
	f = -(x2*x2 + y2*y2 - x3*x3 - y3*y3)
	l = (c*e - b*f)/(a*e - b*d)
	m = (d*c - a*f)/(d*b - e*a)
	n = -(x1*x1 + y1*y1 + l*x1 + m*y1)
	print l*-0.5,m*-0.5,math.sqrt(l*l+m*m-n*4.0)/2.0

Submission status: Runtime Error

Solution code:
import sys

def take2(iterable):
    while True:
        yield next(iterable), next(iterable)
#外積
def cross(v1, v2):
    return v1.real * v2.imag - v1.imag * v2.real
# 線分13と線分24の交点を求める
def get_intersection(p1,p2,p3,p4):
    a1 = p4 - p2
    b1 = p2 - p3
    b2 = p1 - p2
    s1 = cross(a1, b2) / 2
    s2 = cross(a1, b1) / 2
    return p1 + (p3 - p1) * s1 / (s1 + s2)

n = int(f.readline())
for i in range(n):
    p1, p2, p3 = [x + y * 1j for x, y in take2(map(float, f.readline().split()))]
    p12 = (p1 + p2) / 2
    p13 = (p1 + p3) / 2
    pxy = get_intersection(p12,p13,p12 + (p2 - p1) * 1j,p13 + (p1 - p3) * 1j)
    r = abs(pxy - p1)
    print('{:.3f} {:.3f} {:.3f}'.format(pxy.real,pxy.imag,r))

Submission status: Runtime Error

Solution code:
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x2-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2
            a,b,c,d,e,f,=1,0,(x1+x2)/2,1,-a2,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2
            a,b,c,d,e,f,=1,-a1,b1,1,0,(x1+x3)/2
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2
        b2=((y3+y1)-a2*(x1+x3))/2
        a,b,c,d,e,f,=1,-a1,b1,1,-a2,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Submission status: Runtime Error

Solution code:
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2
            a,b,c,d,e,f,=0,1,(x1+x2)/2,-a2,1,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2
            a,b,c,d,e,f,=-a1,1,b1,0,1,(x1+x3)/2
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2
        b2=((y3+y1)-a2*(x1+x3))/2
        a,b,c,d,e,f,=-a1,1,b1,-a2,1,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Submission status: Runtime Error

Solution code:
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2
            a,b,c,d,e,f=0,1,(x1+x2)/2,-a2,1,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2
            a,b,c,d,e,f=-a1,1,b1,0,1,(x1+x3)/2
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2
        b2=((y3+y1)-a2*(x1+x3))/2
        a,b,c,d,e,f=-a1,1,b1,-a2,1,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

n = int(input())

for data in sys.stdin:
    if n <= 0:
        break
    n--
    x1, y1, x2, y2, x3, y3 = map(float, data.split())
    a1 = x2 - x1
    b1 = y2 - y1
    a2 = x3 - x1
    b2 = y3 - y1
    px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
    py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
    r = math.sqrt(px * px + py * py)
    px += x1
    py += y1
    print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r))

Submission status: Runtime Error

Solution code:
# coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

n = int(raw_input())
data = [0 for _ in range(n)]
for i in range(n):
    data[i] = map(float,raw_input().split(' '))
for (x1,y1,x2,y2,x3,y3) in data:
    det = 4*x2*y3 - 4*y2*x3
    px = ((x2**2 + y2**2)*2*y3 - (x3**2 + y3**2)*2*y2)/det
    py = (2*x2*(x3**2 + y3**2) - 2*x3*(x2**2 + y2**2))/det
    r = ((px-x1)**2 + (py-y1)**2)**.5
    print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
i = 0
while i < n:
   x1, y1, x2, y2, x3, y3 = map(float,input().split())
   a = x2 - x1
   b = y2 - y1
   c = x3 - x1
   d = y3 - y1
   e = a * (x1 + x2) + b * (y1 + y3)
   f = c * (x1 + x2) + d * (y1 + y3)
   g = 2.0 * (a * (y3 - y2) - b * (x3 - x2))
   if g == 0:
       exit()
   px = (d * e - b * f) / g
   py = (a * f - c * e) / g
   radius = ( (py - y1)*(py - y1) + (px - x1)*(px - x1) )
   print("%.3f %.3f %.3f"%(px,py,math.sqrt(radius)))

Submission status: Runtime Error

Solution code:
def circum(x1,x2,x3,y1,y2,y3):
    a1 = 2 * (x2 - x1)
    b1 = 2 * (y2 - y1)
    c1 = x1 ** 2 - x2 ** 2 + y1 **2 - y2 ** 2
    a2 = 2 * (x3 - x1)
    b2 = 2 * (y3 - y1)
    c2 = x1 ** 2 - x3 ** 2 + y1 **2 - y3 ** 2
    X = (b1 * c2 - b2 * c1)/(a1 * b2 - a2 * b1)
    Y = (c1 * a2 - c2 * a1)/(a1 * b2 - a2 * b1)
    R = ((x1 - X) ** 2 + (y1 - Y) ** 2) ** 0.5
    return map(lambda n: round(n,3), [X,Y,R])
N = int(input())
ans = []
for i in range(N):
    ans.append(circum(*list(map(float,input().split()))))
for i in range(N):
    print('{0:.3f} {1:.3f} {2:.3f}'.format(*ans[i]))

Submission status: Runtime Error

Solution code:
import sys
import math

if sys.version_info[0] >= 3:
    raw_input = input
N = int(raw_input())
for i in range(N):
    x1, y1, x2, y2, x3, y3 = [float(e) for e in raw_input().split()]
    a1 = 2*x2 - 2*x1
    b1 = 2*y2 - 2*y1
    c1 = x1**2 - x2**2 + y1**2 - y2**2
    a2 = 2 * x3 - 2 * y1
    b2 = 2 * y3 - 2 * y1
    c2 = x1**2 - x3**2 + y1**2 - y3**2
    x = (b1*c2-b2*c1)/(a1*b2-a2*b1)
    y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
    print("%.3f %.3f %.3f" %(x, y, math.hypot(x1-x, y1-y)))

Submission status: Runtime Error

Solution code:
def perpendicular_bisector(p, q):
    x = (q[0] - p[0])
    y = (q[1] - p[1])
    return (2 * x, 2 * y, -x**2 - y**2)


def gauss_jordan_elimination(Array):
    # N???M??????Array
    N = len(Array)
    if N == 0:
        return (True, Array)
    else:
        M = len(Array[0])

    A = []
    for i in range(len(Array)):
        A.append(Array[i][:])

    pivot = 0
    L = min(N, M)
    while pivot < L:
        pivot_v = A[pivot][pivot]
        pivot_row = pivot
        for i in range(pivot + 1, L):
            v = max(A[i][pivot], -A[i][pivot])
            if pivot_v < v:
                pivot_row = i
                pivot_v = v
        if pivot_row > pivot:
            for i in range(M):
                A[pivot][i], A[pivot_row][i] = A[pivot_row][i], A[pivot][i]
        if pivot_v == 0:
            return ('False', A)
        inv_pivot = 1 / A[pivot][pivot]
        A[pivot][pivot] = 1
        for i in range(pivot + 1, M):
            A[pivot][i] *= inv_pivot
        for i in range(N):
            if i == pivot:
                continue
            t = -1 * A[i][pivot]
            A[i][pivot] = 0
            for j in range(pivot + 1, M):
                A[i][j] += t * A[pivot][j]
        pivot += 1
    return ('True', A)

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


    a = list(perpendicular_bisector((x1, y1), (x2, y2)))
    b = list(perpendicular_bisector((x1, y1), (x3, y3)))
    c = [a, b]
    state, c = gauss_jordan_elimination(c)
    x = c[0][2]
    y = c[1][2]
    r = ((x - x1)**2 + (y - y1)**2)**0.5
    print(round(x, 3), round(y, 3), round(r, 3))

Submission status: Runtime Error

Solution code:
import math

n = int(raw_input())

for i in range(n):

  x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())

  px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)))
  py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)))

  r = math.sqrt(pow((x1 - px), 2) + pow((y1 - py), 2))

  print "%.4f %.4f %.4f" % (px, py, r)

Submission status: Runtime Error

Solution code:
import math

n = int(raw_input())

for i in range(n):

  x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())

  px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)))
  py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)))

  r = math.sqrt(pow((x1 - px), 2) + pow((y1 - py), 2))

  print "%.3f %.3f %.3f" % (px, py, r)

Submission status: Runtime Error

Solution code:
import math
x1=0
y1=1
x2=2
y2=3
x3=4
y3=5
n = input()
for _ in xrange(n):
    p = map(float, raw_input().split())
    A = p[x1]**2 - p[x2]**2 + p[y1]**2 - p[y2]**2
    B = 2*p[x1] - 2*p[x2]
    C = 2*p[y1] - 2*p[y2]
    D = p[x1]**2 - p[x3]**2 + p[y1]**2 - p[y3]**2
    E = 2*p[x1] - 2*p[x3]
    F = 2*p[y1] - 2*p[y3]
    b = (A*E-D*B)/(C*E-B*F)
    a = (A*E-C*E*b)/(B*E)
    r = math.sqrt( (p[x1]-a)**2 + (p[y1]-b)**2 )
    print "%.3f %.3f %.3f" % (round(a, 3), round(b, 3), round(r, 3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 x1,y1,x2,y2,x3,y3=[int(i) for i in input().split()]
 px=(x1+x2+x3)/3
 py=(y1+y2+y3)/3
 r=math.sqrt((x1-px)**2+(y1-py)**2)
 print(round(px,3),round(py,3),round(r,3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 x1,y1,x2,y2,x3,y3=[int(i) for i in input().split()]
 p_x=(x1+x2+x3)/3
 p_y=(y1+y2+y3)/3
 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
 print(round(p_x,3),round(p_y,3),round(r,3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 x1,y1,x2,y2,x3,y3=[int(j) for j in input().split()]
 p_x=(x1+x2+x3)/3
 p_y=(y1+y2+y3)/3
 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
 print(round(p_x,3),round(p_y,3),round(r,3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 (x1,y1,x2,y2,x3,y3)=[int(j) for j in input().split()]
 p_x=(x1+x2+x3)/3
 p_y=(y1+y2+y3)/3
 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
 print(round(p_x,3),round(p_y,3),round(r,3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
 p_x=(x1+x2+x3)/3
 p_y=(y1+y2+y3)/3
 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
 print(round(p_x,3),round(p_y,3),round(r,3))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
 x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
 p_x=(x1+x2+x3)/3.0
 p_y=(y1+y2+y3)/3.0
 r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
 print(round(p_x,3),round(p_y,3),round(r,3))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

def length(a, b):
    return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5

def solve_sim_equ(a, b, c, d, e, f):
    '''
    From Problem 0004.
    This function solves following equation.
    ax + by = c
    dx + ey = f
    '''
    if a==0 and d==0:
        if b==0 and e==0:
            return 0., 0.
        if b != 0:
            return 0., c/b+0.
        else:
            return 0., f/e+0.
    elif b==0 and e==0:
        if a != 0:
            return 0., d/a+0.
        else:
            return 0., a/d+0.

    if b == 0:
        a, d = d, a
        b, e = e, b
        c, f = f, c
    g = e / b
    x = (g*c - f) / (g*a - d)
    y = (c - a*x) / b
    return x+0., y+0.


def circumscribed_circle(x, y, z):
    def get_equ_coef(p, q):
        h_x = (p[0] + q[0]) / 2
        h_y = (p[1] + q[1]) / 2
        a = q[1] - p[1]
        b = p[0] - q[0]
        c = b * h_x - a * h_y
        return b, -a, c
    coef = get_equ_coef(x, y) + get_equ_coef(y, z)
    center = solve_sim_equ(*coef)
    r = length(center, x)
    return center, r


def main():
    N = int(input())
    for i in range(N):
        vs = [float(v) for v in input().split()]
        a = (vs[0], vs[1])
        b = (vs[2], vs[3])
        c = (vs[4], vs[5])
        center, r = circumscribed_circle2(a, b, c)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
deta=[float(i) for i in input().split()]
h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
sub=(h1+h2+h3)/2
s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
sum=((h1*h2*h3)/s)/4

a=2*deta[2]-2*deta[0]
b=2*deta[3]-2*deta[1]
c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
d=2*deta[4]-2*deta[2]
e=2*deta[5]-2*deta[3]
f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))

x=(e*c-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum))

Submission status: Runtime Error

Solution code:
from math import sqrt
n=input()
for i in range(n):
	x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
	A1=2*(x2-x1)
	B1=2*(y2-y1)
	C1=x2**2+y2**2-x1**2-y1**2
	x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
	y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1))
	a=sqrt((x2-x1)**2+(y2-y1)**2)
	b=sqrt((x3-x1)**2+(y3-y1)**2)
	c=sqrt((x3-x2)**2+(y3-y2)**2)
	p=(a+b+c)/2
	S=sqrt(p*(p-a)*(p-b)*(p-c))
	R=a*b*c/4/S
	print"%.3f %.3f %.3f"%(x,y,R)

Submission status: Runtime Error

Solution code:
from math import sqrt
n=input()
for i in range(n):
	x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
	A1=2*(x2-x1)
	B1=2*(y2-y1)
	C1=x2**2+y2**2-x1**2-y1**2
	x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
	y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1))

Submission status: Runtime Error

Solution code:
from math import sqrt
n=input()
for i in range(n):
	x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
	A1=2*(x2-x1)
	B1=2*(y2-y1)
	C1=x2**2+y2**2-x1**2-y1**2
	A2=2*(x3-x2)
    B2=2*(y3-y2)
    C2=x3**2+y3**2-x2**2-y2**2

Submission status: Runtime Error

Solution code:
import fractions


def calc(x1, y1, x2, y2):
    return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2


n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    cx1, cy1, z1 = calc(x1, y1, x2, y2)
    cx2, cy2, z2 = calc(x1, y1, x3, y3)
    print(cx1, cy1, z1, cx2, cy2, z2)
    gcd = fractions.gcd(cx1, cx2)
    r1, r2 = cx2 // gcd, cx1 // gcd
    dcy = r1 * cy1 - r2 * cy2
    dz = r1 * z1 - r2 * z2
    y = dz / dcy
    x = (z1 - cy1 * y) / cx1
    r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
    print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r)))

Submission status: Runtime Error

Solution code:
import fractions


def calc(x1, y1, x2, y2):
    return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2


n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    cx1, cy1, z1 = calc(x1, y1, x2, y2)
    cx2, cy2, z2 = calc(x1, y1, x3, y3)
    gcd = fractions.gcd(cx1, cx2)
    r1, r2 = cx2 // gcd, cx1 // gcd
    dcy = r1 * cy1 - r2 * cy2
    dz = r1 * z1 - r2 * z2
    y = dz / dcy
    x = (z1 - cy1 * y) / cx1
    r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
    print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r)))

Submission status: Runtime Error

Solution code:
from math import sqrt 
for _ in range(int(input())) :
    x1, y1, x2, y2, x3, y3 = [float(temp) for temp in input().split()]
    a = [x1, y1, (x1 ** 2) + (y1 ** 2)]
    b = [x2, y2, (x2 ** 2) + (y2 ** 2)]
    c = [x3, y3, (x3 ** 2) + (y3 ** 2)]
    a1 = [(b[0] - a[0]), (b[1] - a[1]), (b[2] - a[2])]
    b1 = [(c[0] - a[0]), (c[1] - a[1]), (c[2] - a[2])]
    a1[1], a1[2] = (a1[1] / a1[0]), (a1[2] / a1[0])
    b1[1], b1[2] = (b1[1] / b1[0]), (b1[2] / b1[0])
    m = -(a1[2] - b1[2]) / (a1[1] - b1[1])
    l = -(a1[1] * m + a1[2])
    n = -((l * a[0]) + (m * a[1]) + a[2])
    px = -l / 2
    py = -m / 2
    r  = sqrt(((l / 2) ** 2)+((m / 2) ** 2)+n)
    print('{:0.3f} {:0.3f} {:0.3f}'.format(px, py, r))

Submission status: Runtime Error

Solution code:
# 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 = .5 * abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y1 - y1))
    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)
    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))

Submission status: Runtime Error

Solution code:
for _ in [0]*int(input()):
    a,d,b,e,c,f=map(float,input().split())
    z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
    x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
    y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
    print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))

Submission status: Runtime Error

Solution code:
for i in range(n):
    x1,y1,x2,y2,x3,y3=map(float, input().split())
    x4,y4=0.5*(x2+x3), 0.5*(y2+y3)
    xg,yg=2/3*(2*x1+x4), 2/3*(2*y1+y4)
    xo,yo=(x1+x2+x3)/3, (y1+y2+y3)/3
    r=((xo-x1)**2+(yo-y1)**2)**0.5
    print(xg, yg, r)

Submission status: Runtime Error

Solution code:
# 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))

Submission status: Runtime Error

Solution code:
# 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))

Submission status: Runtime Error

Solution code:
# 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()

        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))

Submission status: Runtime Error

Solution code:
# 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()

        if points_list[0][0] == points_list[1][0]:
            py = (points_list[0][1] + points_list[1][1])/2
            if points_list[2][1] == points_list[0][1]:
                px = (points_list[0][0] + points_list[2][0])/2
            else:
                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
            if points_list[2][1] == points_list[0][1]:
                px = (points_list[0][0]+points_list[2][0])/2
            else:
                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))

Submission status: Runtime Error

Solution code:
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(int,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-d)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")

Submission status: Runtime Error

Solution code:
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print('.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))

Submission status: Runtime Error

Solution code:
import math
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 s,t,u=a*a+b*b,c*c+d*d,e*e+f*f
 x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print('%.3f %.3f %.3f'%(x,y,math.hypot(x-a,y-b)))

Submission status: Runtime Error

Solution code:
from math import sqrt
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=sqrt((x1-x4)**2+(y1-y4)**2);
	print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
import math
while True:
    t=input()
    if t == "":break
    l=t.split()
    px=sum(l[0::2])/3
    py=sum(l[1::2])/3
    r=math.sqrt((l[0]-px)**2+(l[1]-py)**2)
    print("{0} {1} {2}".format([round(i,3) for i in[px,py,r]]))

Submission status: Runtime Error

Solution code:
import math
input()
while True:
    t=input()
    if t == "":break
    l=[float(i) for i in t.split()]
    px=sum(l[0::2])/3
    py=sum(l[1::2])/3
    r=math.sqrt((l[0]-px)**2+(l[1]-py)**2)
    print("{0} {1} {2}".format([round(i,3) for i in[px,py,r]]))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3=[float(i) for i in 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)))