submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s434711363 | p00010 | Accepted | # 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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s051562628 | p00010 | Accepted | import math
a=int(input())
for i in range(a):
x1,y1,x2,y2,x3,y3=[float(j) for j in input().split()]
A=x1**2+y1**2-x2**2-y2**2
B=x2**2+y2**2-x3**2-y3**2
x12=x1-x2
x23=x2-x3
y12=y1-y2
y23=y2-y3
x=(y23*A-y12*B)/(2*(x12*y23-x23*y12))
if (y12==0):
y=(B-2*x23*x)/(2*y23)
else:
y=(A-2*x12*x)/(2*y12)
r=math.sqrt((x1-x)**2+(y1-y)**2)
print('{:.3f} {:.3f} {:.3f}'.format(x,y,r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s075153499 | p00010 | Accepted | for _ in range(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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s779675306 | p00010 | Accepted | def pp(x):
if x==0:
x=0
return "{0:.3f}".format(round(x,3))
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float, input().split())
a=2*(x2-x1)
b=2*(y2-y1)
c=( x2**2 + y2**2 ) - ( x1**2 + y1**2 )
d=2*(x3-x1)
e=2*(y3-y1)
f=( x3**2 + y3**2 ) - ( x1**2 + y1**2 )
x=(c*e-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
r=( (x-x1)**2 + (y-y1)**2 )**0.5
print(pp(x), pp(y), pp(r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s751225048 | p00010 | Accepted | def line(grad, x, y):
return [grad, y - grad * x]
def intersection(a, b, c, d):
return [-(b-d)/(a-c), -(b-d)/(a-c)*a+b]
n = input()
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
a, b = line(-1 / ((y1 - y2) / (x1 - x2 + 0.000000001) + 0.000000001), (x1 + x2) / 2, (y1 + y2) / 2)
c, d = line(-1 / ((y3 - y2) / (x3 - x2 + 0.000000001) + 0.000000001), (x3 + x2) / 2, (y3 + y2) / 2)
px, py = intersection(a, b, c, d)
print "%.3f %.3f %.3f" % (px, py, ((px - x1)**2 + (py - y1)**2)**0.5) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s784075347 | p00010 | Accepted | # 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
elif points_list[0][1] == points_list[1][1]:
px = (points_list[0][0] + points_list[1][0])/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
py = a2*px + b2
elif points_list[0][1] == points_list[2][1]:
px = (points_list[0][0] + points_list[2][0])/2
a1_s = (points_list[1][1] - points_list[0][1]) / (points_list[1][0] - points_list[0][0])
a1 = -1 / a1_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
b1 = m12y - a1 * m12x
py = a1 * px + b1
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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s872566194 | p00010 | Accepted | n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
px = ((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))
py = ((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)-2*(x1-x2)*(y1-y3))
r = ((x1 - px)**2 + (y1 - py)**2)**0.5
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s420506779 | p00010 | Accepted | 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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s966441617 | p00010 | Accepted | n = int(raw_input())
i = 0
while (i < n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
m1,m2=(x1+x2) / 2, (y1+y2) / 2
n1,n2=(x1+x3) / 2, (y1+y3) / 2
if y1==y2:
a = 1
b = 0
c = m1
elif x1==x2:
a = 0
b = 1
c = m2
else:
a = (x2-x1) / (y2-y1)
b = 1
c = m2+a*m1
if y1==y3:
d = 1
e = 0
f = n1
elif x1==x3:
d = 0
e = 1
f = n2
else:
d = (x3-x1) / (y3-y1)
e = 1
f = n2+d*n1
if a*d-b*c==0:
print "not exist answer"
else:
x = (float((c*e-b*f)) / (a*e-b*d))+0
y = (float((a*f-c*d)) / (a*e-b*d))+0
print ('%.3f' % round(x,3)), ('%.3f' % round(y,3)), ('%.3f' % round(((((x - x1)**2+(y-y1)**2)**0.5)),3))
i += 1 | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s891334405 | p00010 | Accepted | import math
N = int(input())
for i in range(N):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
x =((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3)))
y =((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3)))
r = (x-x1)*(x-x1)+(y-y1)*(y-y1)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,math.sqrt(r)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s516115277 | p00010 | Accepted | n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a = pow((x3-x2) ** 2 + (y3-y2) ** 2, 0.5)
b = pow((x3-x1) ** 2 + (y3-y1) ** 2, 0.5)
c = pow((x1-x2) ** 2 + (y1-y2) ** 2, 0.5)
cosA = (b**2 + c**2 - a**2) / (2*b*c)
sinA = pow(1 - cosA**2, 0.5)
R = a / sinA / 2
a, b, c = x1-x2, y1-y2, -(x1**2 + y1**2) + (x2**2 + y2**2)
d, e, f = x2-x3, y2-y3, -(x2**2 + y2**2) + (x3**2 + y3**2)
l = (c*e - b*f) / (e*a - b*d)
m = (c*d - a*f) / (b*d - a*e)
l, m = l*-0.5, m*-0.5
print("{:.3f} {:.3f} {:.3f}".format(l, m, R))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s275837697 | p00010 | Accepted | import math
N = int(input())
for l in range(N):
x1,y1,x2,y2,x3,y3 = [float(i) for i in input().split()]
# ax + by = e
# cx + dy = f
a,b,c = x1-x2, y1-y2, (x1-x2)*(x1+x2)/2 + (y1-y2)*(y1+y2)/2
d,e,f = x1-x3, y1-y3, (x1-x3)*(x1+x3)/2 + (y1-y3)*(y1+y3)/2
X = (c*e-f*b)/(a*e-b*d)
Y = (f*a-c*d)/(a*e-b*d)
R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1))
print(format(X, '.3f'), format(Y, '.3f'), format(R, '.3f'))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s311357839 | p00010 | Accepted | 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(f"{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}")
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s265666860 | p00010 | Accepted | 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))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s766615770 | p00010 | Accepted | 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,((x-a)**2+(y-b)**2)**.5))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s920772895 | p00010 | Accepted | 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)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s820563602 | p00010 | Accepted | 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
x=(C1*B2-C2*B1)/(A1*B2-A2*B1)
y=(A1*C2-A2*C1)/(A1*B2-A2*B1)
R=sqrt((x1-x)**2+(y1-y)**2)
print"%.3f %.3f %.3f"%(x,y,R)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s029881406 | p00010 | Accepted | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
A=math.hypot(x2-x3,y2-y3)**2
B=math.hypot(x1-x3,y1-y3)**2
C=math.hypot(x1-x2,y1-y2)**2
t1=A*(B+C-A)
t2=B*(A+C-B)
t3=C*(A+B-C)
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("%.3f %.3f %.3f"%(round(px,3),round(py,3),round(r,3)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s655711077 | p00010 | Accepted | 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(f'{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}')
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s514957818 | p00010 | Accepted | 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)
p = abs(p) if abs(p) < 10e-5 else p
q = abs(q) if abs(q) < 10e-5 else q
print("{:.3f} {:.3f} {:.3f}".format(p, q, r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s441020577 | p00010 | Accepted | 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))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s642943574 | p00010 | Accepted | # -*- coding: utf-8 -*-
from math import sqrt
# import numpy as np
n = int(input())
for i in range(n):
tmp = input().split(' ')
a, b, c = [(float(tmp[i]), float(tmp[i+1])) for i in range(0, len(tmp), 2)]
#A = np.array(((a[0], a[1], 1),
# (b[0], b[1], 1),
# (c[0], c[1], 1)))
A_tmp1 = 1/(a[0]*b[1] + a[1]*c[0] + b[0]*c[1] - b[1]*c[0] - a[1]*b[0] - a[0]*c[1])
A_tmp2 = [[b[1]-c[1], -(a[1]-c[1]), a[1]-b[1]],
[-(b[0]-c[0]), (a[0]-c[0]), -(a[0]-b[0])],
[b[0]*c[1] - b[1]*c[0], -(a[0]*c[1] - a[1]*c[0]), a[0]*b[1] - a[1]*b[0]]]
A = [list(map(lambda x: A_tmp1*x, A_tmp2[i])) for i in range(3)]
#B = np.array((((-(a[0]**2 + a[1]**2))),
# ((-(b[0]**2 + b[1]**2))),
# ((-(c[0]**2 + c[1]**2)))))
B = [[-(a[0]**2 + a[1]**2)],
[-(b[0]**2 + b[1]**2)],
[-(c[0]**2 + c[1]**2)]]
tmp = [sum([A[i][j]*B[j][0] for j in range(3)]) for i in range(3)]
# tmp = np.dot(np.linalg.inv(A), B)
x = -tmp[0]/2
y = -tmp[1]/2
r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4)
print('{:.3f} {:.3f} {:.3f}'.format(x, y, r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s975589080 | p00010 | Accepted | #!/usr/bin/env python
from math import *
def g(x):
y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
if x < 0:
y *= -1
return y
def func(x):
x1, y1, x2, y2, x3, y3 = x
a = x1 - x2
b = y1 - y2
c = (x1 * x1 + y1 * y1 - x2 * x2 - y2 * y2) / 2
d = x1 - x3
e = y1 - y3
f = (x1 * x1 + y1 * y1 - x3 * x3 - y3 * y3) / 2
x = (e * c - b * f) / (a * e - b * d)
y = (a * f - d * c) / (a * e - b * d)
r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y))
x = "{0:.3f}".format(g(x))
y = "{0:.3f}".format(g(y))
r = "{0:.3f}".format(g(r))
print(x + " " + y + " " + r)
n = int(input())
a = []
for _ in range(n):
a.append(list((map(float, input().split()))))
for i in a:
func(i)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s051503729 | p00010 | Accepted | #!/usr/bin/env python
from math import *
def g(x):
y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
if x < 0:
y *= -1
return y
def func(x):
x1, y1, x2, y2, x3, y3 = x
vx1 = x2 - x1
vy1 = y2 - y1
vx2 = x3 - x1
vy2 = y3 - y1
k = (vx2 ** 2 + vy2 ** 2 - vx1 * vx2 - vy1 * vy2) / (vy1 * vx2 - vx1 * vy2) / 2
x = vx1 / 2 + k * vy1 + x1
y = vy1 / 2 - k * vx1 + y1
r = sqrt((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y))
x = "{0:.3f}".format(g(x))
y = "{0:.3f}".format(g(y))
r = "{0:.3f}".format(g(r))
print(x + " " + y + " " + r)
n = int(input())
a = []
for _ in range(n):
a.append(list((map(float, input().split()))))
for i in a:
func(i)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s478922477 | p00010 | Accepted | from math import *
def g(x):
y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
if x < 0:
y *= -1
return y
'''
def f(x):
a = (x[2] - x[4]) * (x[1] - x[3]) - (x[0] - x[2]) * (x[3] - x[5])
b = (x[0] - x[2]) * (x[4] - x[0]) - (x[5] - x[1]) * (x[1] - x[3])
l = 0.5 * b / a
X = 0.5 * x[2] + 0.5 * x[4] + l * (x[3] - x[5])
Y = 0.5 * x[3] + 0.5 * x[5] + l * (x[4] - x[2])
R = sqrt((X - x[0]) ** 2 + (Y - x[1]) ** 2)
X = g(X)
Y = g(Y)
R = g(R)
print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
'''
def f(x):
x1, y1, x2, y2, x3, y3 = x
X1 = x1 - x3
Y1 = y1 - y3
X2 = x2 - x3
Y2 = y2 - y3
k = (X2 ** 2 + Y2 ** 2 -X1 * X2 - Y1 * Y2) / (2 * (X2 * Y1 - X1 * Y2))
X = X1 / 2 + k * Y1 + x3
Y = Y1 / 2 - k * X1 + y3
R = sqrt((X - x1) ** 2 + (Y - y1) ** 2)
X = g(X)
Y = g(Y)
R = g(R)
print("{0:.3f} {1:.3f} {2:.3f}".format(X, Y, R))
n = int(input())
a = []
for _ in range(n):
a.append(list((map(float, input().split()))))
for i in a:
f(i)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s609033297 | p00010 | Accepted | #!/usr/bin/env python
from math import *
def g(x):
y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
if x < 0:
y *= -1
return y
def func(x):
x1, y1, x2, y2, x3, y3 = x
vx1 = x2 - x1
vy1 = y2 - y1
vx2 = x3 - x1
vy2 = y3 - y1
k = (vx2 ** 2 + vy2 ** 2 - vx1 * vx2 - vy1 * vy2) / (vy1 * vx2 - vx1 * vy2) / 2
x = vx1 / 2 + k * vy1 + x1
y = vy1 / 2 - k * vx1 + y1
r = sqrt((x1 - x) ** 2 + (y1 - y) ** 2)
print("{0:.3f} {1:.3f} {2:.3f}".format(g(x), g(y), g(r)))
n = int(input())
for _ in range(n):
func(list(map(float, input().split())))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s759661770 | p00010 | Accepted | 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]]))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s959923226 | p00010 | Accepted | # AOJ 0010 Circumscribed Circle of a Triangle
# Python3 2018.6.22 bal4u
import math
EPS = 1e-8
def cross(a, b):
return a.real*b.imag - a.imag*b.real
def dist(a, b):
return math.hypot(a.real-b.real, a.imag-b.imag)
# 両直線の交点
def crossPointLL(ln1, ln2):
u = ln1[1]-ln1[0]
v = ln2[1]-ln2[0]
return ln1[0] + u*(cross(v, ln2[0]-ln1[0])/cross(v, u))
# 入力:3点座標、リターン:外接円の円心座標、半径を表すリスト
def circumscribed_circle(p1, p2, p3):
p12 = (p1+p2)/2
p23 = (p2+p3)/2
ln1 = [p12, p12+(p1-p2)*complex(0, 1)]
ln2 = [p23, p23+(p2-p3)*complex(0, 1)]
c = crossPointLL(ln1, ln2)
return [c, dist(c, p1)]
for i in range(int(input())):
p = list(map(float, input().split()))
p1 = complex(p[0], p[1])
p2 = complex(p[2], p[3])
p3 = complex(p[4], p[5])
ans = circumscribed_circle(p1, p2, p3)
print(format(ans[0].real+EPS, ".3f"), format(ans[0].imag+EPS, ".3f"), format(ans[1]+EPS, ".3f"))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s259787433 | p00010 | Accepted |
import math
PI = math.pi
EPS = 10**-10
def edge(a, b):
return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5
def area(a, b, c):
s = (a+b+c)/2
return (s*(s-a)*(s-b)*(s-c))**.5
def LawOfCosines(a, b, c): #余弦定理
return math.acos( (b*b+c*c-a*a) / (2.0*b*c) );
def is_same(x, y):
return abs(x-y) < EPS
class Triangle:
def __init__(self, p):
a, b, c = p
self.a = a
self.b = b
self.c = c
self.edgeA = edge(b, c)
self.edgeB = edge(c, a)
self.edgeC = edge(a, b)
self.area = area(self.edgeA, self.edgeB, self.edgeC)
self.angleA = LawOfCosines(self.edgeA, self.edgeB, self.edgeC)
self.angleB = LawOfCosines(self.edgeB, self.edgeC, self.edgeA)
self.angleC = LawOfCosines(self.edgeC, self.edgeA, self.edgeB)
def circumscribeadCircleRadius(self): #外接円の半径を返す
return self.edgeA / math.sin(self.angleA) / 2.0
def circumscribedCircleCenter(self): #外接円の中心の座標を返す
a = math.sin(2.0*self.angleA);
b = math.sin(2.0*self.angleB);
c = math.sin(2.0*self.angleC);
X = (self.a[0] * a + self.b[0] * b + self.c[0] * c) / (a+b+c);
Y = (self.a[1] * a + self.b[1] * b + self.c[1] * c) / (a+b+c);
return X, Y
def inscribedCircleRadius(self): #内接円の半径
return 2 * self.area / (self.edgeA + self.edgeB + self.edgeC)
def inscribedCircleCenter(self): #内接円の中心の座標
points = [self.a, self.b, self.c]
edges = [self.edgeA, self.edgeB, self.edgeC]
s = sum(edges)
return [sum([points[j][i]*edges[j] for j in range(3)])/s for i in range(2)]
def isInner(self, p): #点が三角形の内側か判定
cross = lambda a, b: a[0]*b[1]-a[1]*b[0]
c1 = 0
c2 = 0
points = [self.a, self.b, self.c]
for i in range(3):
a = [points[i][0]-points[(i+1)%3][0], points[i][1]-points[(i+1)%3][1]]
b = [points[i][0]-p[0], points[i][1]-p[1]]
c = cross(a, b)
if c > 0:
c1 += 1
elif c < 0:
c2 += 1
if c1 == 3 or c2 == 3:
return True
else:
return c1+c2 != 3 and (c1 == 0 or c2 == 0)
if __name__ == "__main__":
n = int(input())
for _ in range(n):
points = []
c = list(map(float, input().split()))
points = [(c[i], c[i+1]) for i in range(0, 6, 2)]
t = Triangle(points)
#外接円
x, y = t.circumscribedCircleCenter()
r = t.circumscribeadCircleRadius()
print("{:.3f} {:.3f} {:.3f}".format(x,y,r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s684388383 | p00010 | Accepted | import math
def calc(x, y):
s = math.fabs((x[1]-x[0])*(y[2]-y[0]) - (x[2]-x[0])*(y[1]-y[0]))/2
a = ((x[2]-x[1])**2 + (y[2]-y[1])**2)**0.5
b = ((x[0]-x[2])**2 + (y[0]-y[2])**2)**0.5
c = ((x[1]-x[0])**2 + (y[1]-y[0])**2)**0.5
r = a*b*c/(4*s)
a = [2*(x[1]-x[0]), 2*(x[2]-x[0])]
b = [2*(y[1]-y[0]), 2*(y[2]-y[0])]
c = [x[0]**2 - x[1]**2 + y[0]**2 -y[1]**2, x[0]**2 - x[2]**2 + y[0]**2 -y[2]**2]
x = (b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0])
y = (c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0])
return [x,y,r]
for i in range(int(input())):
list = [float(l) for l in raw_input().split()]
x,y = [list[0::2],list[1::2]]
ans = calc(x,y)
print "%.3f %.3f %.3f" % (ans[0],ans[1],ans[2]) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s639938597 | p00010 | Accepted | import sys
n=input()
for line in sys.stdin:
x=map(float,line.split())[0::2];
y=map(float,line.split())[1::2];
#guilty...
A=x[0]-x[1]
B=y[0]-y[1]
C=x[1]-x[2]
D=y[1]-y[2]
E=-(x[0]**2+y[0]**2)+(x[1]**2+y[1]**2)
F=-(x[1]**2+y[1]**2)+(x[2]**2+y[2]**2)
l=(D*E-B*F)/(A*D-B*C)
m=(-C*E+A*F)/(A*D-B*C)
n=-(x[0]**2+y[0]**2+l*x[0]+m*y[0])
print "{:.3f} {:.3f} {:.3f}".format(-l/2,-m/2,(l**2+m**2-4*n)**0.5/2) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s199572648 | p00010 | Accepted | #coding: utf-8
def solve(a, b, c, d, e, f):
agn = a*e - b*d
x = (e*c - b*f)/float(agn)
y = (-d*c + a*f)/float(agn)
if x == 0.: x = 0.
if y == 0.: y = 0.
return (x, y)
while 1:
try:
n = input()
for i in xrange(n):
x = [0 for i in xrange(3)]
y = [0 for i in xrange(3)]
a,b,t = [[0 for i in xrange(2)] for i in xrange(3)]
p,q,s = [[0 for i in xrange(2)] for i in xrange(3)]
x[0],y[0],x[1],y[1],x[2],y[2] = map(float, raw_input().split())
for j in xrange(2):
a[j] = (x[j+1] + x[j])/2
b[j] = (y[j+1] + y[j])/2
if x[j+1] - x[j] == 0.:
p[j] = 0.
q[j] = -1.
s[j] = -b[j]
elif y[j+1] - y[j] == 0.:
p[j] = -1.
q[j] = 0.
s[j] = -a[j]
else:
t[j] = (y[j+1] - y[j]) / (x[j+1] - x[j])
p[j] = -1./t[j]
q[j] = -1.
s[j] = -(a[j]/t[j])-b[j]
c = solve(p[0], q[0], s[0], p[1], q[1], s[1])
r = ((x[0]-c[0])**2 + (y[0]-c[1])**2)**0.5
print "%.3f %.3f %.3f" % (c[0], c[1], r)
except EOFError:
break | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s354229444 | p00010 | Accepted | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
def gaishin(a,b,c,z1,z2,z3,s):
p = (a**2*(b**2 + c**2 - a**2)*z1 + \
b**2*(c**2 + a**2 - b**2)*z2 + \
c**2*(a**2 + b**2 - c**2)*z3)/(16*s**2)
return p
n = input()
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float, raw_input().split(' '))
l1 = ((x2-x3)**2+(y2-y3)**2)**0.5
l2 = ((x3-x1)**2+(y3-y1)**2)**0.5
l3 = ((x1-x2)**2+(y1-y2)**2)**0.5
s = heron(l1,l2,l3)
px = gaishin(l1,l2,l3,x1,x2,x3,s)
py = gaishin(l1,l2,l3,y1,y2,y3,s)
r = ((px-x1)**2+(py-y1)**2)**0.5
print '%.3f %.3f %.3f' % (px,py,r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s455473437 | p00010 | Accepted | import math
from math import *
for i in range(int(raw_input())):
(x1, y1, x2, y2, x3, y3) = map(float, raw_input().split())
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
xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
r = sqrt((x1 - xp) ** 2 + (y1 - yp) ** 2)
print '%.3f %.3f %.3f' % (xp, yp, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s009430967 | p00010 | Accepted | import math
def calc(x, y):
s = math.fabs((x[1]-x[0])*(y[2]-y[0]) - (x[2]-x[0])*(y[1]-y[0]))/2
a = ((x[2]-x[1])**2 + (y[2]-y[1])**2)**0.5
b = ((x[0]-x[2])**2 + (y[0]-y[2])**2)**0.5
c = ((x[1]-x[0])**2 + (y[1]-y[0])**2)**0.5
r = a*b*c/(4*s)
a = [2*(x[1]-x[0]), 2*(x[2]-x[0])]
b = [2*(y[1]-y[0]), 2*(y[2]-y[0])]
c = [x[0]**2 - x[1]**2 + y[0]**2 -y[1]**2, x[0]**2 - x[2]**2 + y[0]**2 -y[2]**2]
x = (b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0])
y = (c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0])
return [x,y,r]
for i in range(int(input())):
list = [float(l) for l in raw_input().split()]
x,y = [list[0::2],list[1::2]]
ans = calc(x,y)
print "%.3f %.3f %.3f" % (ans[0],ans[1],ans[2]) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s725673573 | p00010 | Accepted | from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
from math import sqrt
N = int(stdin.readline())
for i in xrange(N):
x1, y1, x2, y2, x3, y3 = (float(n) for n in stdin.readline().split())
det = x1*y2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 - x3*y2
a = x1**2 + y1**2
b = x2**2 + y2**2
c = x3**2 + y3**2
L = (a*y2 + b*y3 + c*y1 - a*y3 - b*y1 - c*y2) / det
M = (x1*b + x2*c + x3*a - x1*c - x2*a - x3*b) / det
N = (x1*y2*c + x2*y3*a + x3*y1*b - x1*y3*b - x2*y1*c - x3*y2*a) / det
xp = L / 2.0
yp = M / 2.0
r = sqrt(abs(N + xp**2.0 + yp**2.0))
print('{:.3f} {:.3f} {:.3f}'.format(xp, yp, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s574348966 | p00010 | Accepted | from math import sqrt
ans=[]
n=input()
for i in xrange(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
A2=2*(x3-x1)
B1=2*(y2-y1)
B2=2*(y3-y1)
C1=x1**2-x2**2+y1**2-y2**2
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=sqrt((x-x1)**2 + (y-y1)**2)
ansstr='%.3f %.3f %.3f' % (x,y,r)
ans.append(ansstr)
for i in ans:
print i | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s526999589 | p00010 | Accepted | import sys
from math import sqrt
n = input()
for line in sys.stdin:
[x1,y1,x2,y2,x3,y3] = [float(x) for x in line.split()]
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)
a = sqrt((x2-x1)**2 + (y2-y1)**2)
b = sqrt((x3-x1)**2 + (y3-y1)**2)
c = sqrt((x3-x2)**2 + (y3-y2)**2)
r = (a*b*c)/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c))
print "%.3f %.3f %.3f" % (x,y,r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s911748786 | p00010 | Accepted | import math
a = int(raw_input())
while a > 0:
a -= 1
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
a1 = 2*(x2-x1)
b1 = 2*(y2-y1)
c1 = x1*x1-x2*x2+y1*y1-y2*y2
a2 = 2*(x3-x1)
b2 = 2*(y3-y1)
c2 = x1*x1-x3*x3+y1*y1-y3*y3
X = (b1*c2-b2*c1)/(a1*b2-a2*b1)
Y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1))
print "%.3f %.3f %.3f" % (X,Y,R) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s904662742 | p00010 | Accepted | import math
a = int(raw_input())
while a > 0:
a -= 1
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
a1 = 2*(x2-x1)
b1 = 2*(y2-y1)
c1 = x1*x1-x2*x2+y1*y1-y2*y2
a2 = 2*(x3-x1)
b2 = 2*(y3-y1)
c2 = x1*x1-x3*x3+y1*y1-y3*y3
X = (b1*c2-b2*c1)/(a1*b2-a2*b1)
Y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1))
print "%.3f %.3f %.3f" % (X,Y,R) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s241429082 | p00010 | Accepted | import math
def equation(A):
n = len(A)
for i in range(n):
j=i
while A[j][i]==0:
j+= 1
A[i], A[j] = A[j], A[i]
A[i] = [e / A[i][i] for e in A[i]]
for j in range(n):
if j==i: continue
tmp = A[j][i]
for k in range(n+1):
A[j][k] -= tmp * A[i][k]
return
n=input()
for i in range(n):
A=[]
seq = map(float, raw_input().split())
for j in range(3):
x = seq.pop(0)
y = seq.pop(0)
A.append([x, y, 1, -(x**2+y**2)])
equation(A)
x0, y0 = -A[0][3]/2, -A[1][3]/2
r =((x-x0)**2 + (y-y0)**2)**.5
print "%.3f %.3f %.3f" %(x0, y0, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s336615626 | p00010 | Accepted | import math
n = int(raw_input())
for _ in range(n):
(x1, y1, x2, y2, x3, y3) = map(float, raw_input().split())
a1 = (x2 - x1) * 2
a2 = (x3 - x1) * 2
b1 = (y2 - y1) * 2
b2 = (y3 - y1) * 2
c1 = x1**2 - x2**2 + y1**2 - y2**2
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 = math.sqrt((x-x1)**2 + (y-y1)**2)
print '{0:.3f} {1:.3f} {2:.3f}'.format(x, y, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s831575306 | p00010 | Accepted | # -*- coding: utf-8 -*-
import sys
import math
n = 0
datas = []
for (i, line) in enumerate(sys.stdin):
if i == 0:
n = int(line)
else:
datas.append(map(float, line.split()))
for data in datas:
x1, y1, x2, y2, x3, y3 = data
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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s678331748 | p00010 | Accepted | # Circumscribed Circle of a Triangle
import sys
import math
n = 0
datas = []
for (i, line) in enumerate(sys.stdin):
if i == 0:
n = int(line)
else:
datas.append(map(float, line.split()))
for data in datas:
x1, y1, x2, y2, x3, y3 = data
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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s001056118 | p00010 | Accepted |
import math
n = input()
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
d1 = x1 * x1 + y1 * y1;
d2 = x2 * x2 + y2 * y2;
d3 = x3 * x3 + y3 * y3;
u = 0.5 / ( x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3)
xp = u* (d1 * y2 - d2 * y1 + d2 * y3 - d3 * y2 + d3 * y1 - d1 * y3)
yp = u * (x1 * d2 - x2 * d1 + x2 * d3 - x3 * d2 + x3 * d1 - x1 * d3)
r = math.sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1))
print "%.3f %.3f %.3f" % (xp, yp, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s148157877 | p00010 | Accepted | import math
def equation(A):
n=len(A)
for i in range(n):
j=i
while A[j][i]==0:j+=1
A[i],A[j]= A[j],A[i]
A[i]=[e/A[i][i] for e in A[i]]
for j in range(n):
if j==i: continue
tmp=A[j][i]
for k in range(n+1):A[j][k]-=tmp*A[i][k]
return
n=input()
for i in range(n):
A=[]
seq=map(float,raw_input().split())
for j in range(0,6,2):
x,y=seq[j:j+2]
A+=[[x,y,1,-(x**2+y**2)]]
equation(A)
x0=-A[0][3]/2
y0=-A[1][3]/2
r=((x-x0)**2+(y-y0)**2)**.5
print "%.3f %.3f %.3f" %(x0,y0,r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s460236051 | p00010 | Accepted | # -*- coding: utf-8 -*-
import sys
def prod_mat_vec(A, vec):
ret = [0 for i in xrange(3)]
for i in xrange(3):
for j in xrange(3):
ret[i] += A[i][j] * vec[j]
return ret
def changerow(A, i1, i2):
for j in xrange(3):
buf = A[i1][j]
A[i1][j] = A[i2][j]
A[i2][j] = buf
return A
def MatrixInverse3x3(A_src):
A = [ [A_src[i][j] for j in xrange(3)] for i in xrange(3) ] # deepcopy A_src -> A
B = [ [1, 0, 0], \
[0, 1, 0], \
[0, 0, 1] ]
for i in xrange(3):
if A[i][i] == 0:
for k in xrange(i+1, 3):
if A[k][k] != 0:
A = changerow(A, i, k)
B = changerow(B, i, k)
a = A[i][i]
for j in xrange(3):
A[i][j] /= a
B[i][j] /= a
for k in xrange(3):
if i == k: continue
a = A[k][i]
for j in xrange(3):
A[k][j] -= A[i][j] * a
B[k][j] -= B[i][j] * a
return B
def output3x3(A):
for i in xrange(3):
print "%7.3f %7.3f %7.3f" % (A[i][0], A[i][1], A[i][2])
return
#for line in ["0.0 3.0 -1.0 0.0 -3.0 4.0"]: # expected [-2.000, 2.000, 2.236]
for line in sys.stdin.readlines():
List = map(float, line.strip().split())
if len(List) == 1: continue
[x1, y1, x2, y2, x3, y3] = List
A = [ [x1, y1, 1.0] ,\
[x2, y2, 1.0] ,\
[x3, y3, 1.0] ]
vec = [x1**2+y1**2, x2**2+y2**2, x3**2+y3**2]
B = MatrixInverse3x3(A)
lmn = prod_mat_vec(B, vec)
ans = [0.5*lmn[0], 0.5*lmn[1], (lmn[2]+0.25*lmn[0]**2+0.25*lmn[1]**2)**0.5]
print "%.3f %.3f %.3f" % (ans[0], ans[1], ans[2])
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s813095975 | p00010 | Accepted | import sys,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*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
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))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s612749846 | p00010 | Accepted | import math
n = int(raw_input())
while True:
try:
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
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
ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
sina = 2*ss/b/c
sinb = 2*ss/a/c
sinc = 2*ss/a/b
r = a/sina/2
a = a*a
b = b*b
c = c*c
px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/ss**2
py =(a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/ss**2
print "%.3f %.3f %.3f" % (px, py, r)
except:
break | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s380242787 | p00010 | Accepted | import math
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
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
ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
sina = 2*ss/b/c
r = a/sina/2
a = a*a
b = b*b
c = c*c
px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/ss**2
py =(a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/ss**2
print "%.3f %.3f %.3f" % (px, py, r) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s243207823 | p00010 | Accepted | import sys
import math
n = int(raw_input())
for data in sys.stdin:
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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s591258207 | p00010 | Accepted | from math import hypot
T = input()
for t in xrange(1, T + 1):
x1, y1, x2, y2, x3, y3 = map(float, raw_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 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) /
(2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3)))
print "%.3f %.3f %.3f" % (x4, y4, hypot(x1 - x4, y1 - y4)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s954505556 | p00010 | Accepted | #!/usr/bin/python
import sys,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*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
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))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s532964118 | p00010 | Accepted | from math import hypot
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().strip().split())
d = lambda x, y: x*x + y*y
t21 = [2*(x2-x1), 2*(y2-y1), d(x2,y2) - d(x1,y1)]
t31 = [2*(x3-x1), 2*(y3-y1), d(x3,y3) - d(x1,y1)]
det = lambda i, j: t21[i]*t31[j] - t21[j]*t31[i]
a = det(2,1) / det(0,1)
b = det(0,2) / det(0,1)
r = hypot(x1-a, y1-b)
print('{:.3f} {:.3f} {:.3f}'.format(a, b, r)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s240476404 | p00010 | Accepted | def f1(a, b, c, d): # 2点の中心を通り垂直な線の傾きと切片
k = (a - c) / (d - b)
h = ((b + d) - k * (a + c)) / 2
return k, h
def f2(a, b, c, d): # 2直線との交点
x = (d - b) / (a - c)
y = a * x + b
return x, y
def f3(a, b, c, d):
return ((c - a) ** 2 + (d - b) ** 2) ** 0.5
def main():
N = int(input())
for i in range(N):
a, b, c, d, e, f = map(float, input().split())
T = []
if not b == d:
k, h = f1(a, b, c, d)
T.append((k, h))
if not d == f:
k, h = f1(c, d, e, f)
T.append((k, h))
if not f == b:
k, h = f1(e, f, a, b)
T.append((k, h))
x, y = f2(T[0][0], T[0][1], T[1][0], T[1][1])
r = f3(x, y, a, b)
print(f'{round(x, 3):.3f} {round(y, 3):.3f} {round(r, 3):.3f}')
if __name__ == '__main__':
main()
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s353335724 | p00010 | Accepted | n = int(input())
for i in range(n):
lst = list(map(float, input().split()))
a, b = lst[0], lst[1]
c, d = lst[2], lst[3]
e, f = lst[4], lst[5]
px = ((a+c)*(a-c)*(b-f)-(a+e)*(a-e)*(b-d)+(b-d)*(b-f)*(d-f))/(2*((a-c)*(b-f)-(a-e)*(b-d)))
py = ((a-c)*(a-e)*(c-e)+(b+d)*(b-d)*(a-e)-(b+f)*(b-f)*(a-c))/(2*((b-d)*(a-e)-(b-f)*(a-c)))
r = ((a-px)**2 + (b-py)**2)**0.5
print('{:.3f}'.format(px), end= " ")
print('{:.3f}'.format(py), end= " ")
print('{:.3f}'.format(r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s120875423 | p00010 | Accepted | import math
for i in range(int(input())):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
a = 2*(x2 - x1)
b = 2*(y2 - y1)
c = x1**2 - x2**2 + y1**2 - y2**2
aa = 2*(x3 - x1)
bb = 2*(y3 - y1)
cc = x1**2 - x3**2 + y1**2 - y3**2
x = (b*cc - bb*c) / (a*bb - aa*b)
y = (c*aa - cc*a) / (a*bb - aa*b)
r = math.hypot(x1 - x,y1 - y)
print(f'{x:.03f} {y:.03f} {r:.03f}')
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s378328852 | p00010 | Accepted | import math
N=int(input())
for i in range(N):
x1,y1,x2,y2,x3,y3=[float(e) for e in input().split()]
a1=2*x2-2*x1
b1=2*y2-2*y1
c1=x1*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
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)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s097941839 | p00010 | Accepted | import math
n = int(input())
for i in range(n) :
x1, y1, x2, y2, x3, y3 = map(float, input().split())
py = ((x3-x1)*(x1**2 + y1**2 - x2**2 - y2**2) - (x2-x1)*(x1**2 + y1**2 - x3**2 - y3**2)) / (2*(x3-x1)*(y1-y2) - 2*(x2-x1)*(y1-y3))
if x1 == x2 :
px = (2*(y1-y3)*py - x1**2 - y1**2 + x3**2 + y3**2) / (2*(x3 - x1))
else :
px = (2*(y1-y2)*py - x1**2 - y1**2 + x2**2 + y2**2) / (2*(x2 - x1))
r = math.sqrt((px - x1)**2 + (py -y1)**2)
print('{:.3f}'.format(px), '{:.3f}'.format(py), '{:.3f}'.format(r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s311774112 | p00010 | Accepted | N = int(input())
for i in range(N):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a = 2*(x1 - x2); b = 2*(y1 - y2); p = x1**2 - x2**2 + y1**2 - y2**2
c = 2*(x1 - x3); d = 2*(y1 - y3); q = x1**2 - x3**2 + y1**2 - y3**2
det = a*d - b*c
x = d*p - b*q; y = a*q - c*p
if det < 0:
x = -x; y = -y; det = -det
x /= det; y /= det
r = ((x - x1)**2 + (y - y1)**2)**.5
print("%.03f %.03f %.03f" % (x, y, r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s713460365 | p00010 | Accepted | import math
class Circle:
def __init__(self,x,y,r):
self.x = x
self.y = y
self.r = r
def getCircle(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 Circle(px,py,r)
n = int(input())
for k in range(n):
x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split()]
circle = getCircle(x1, y1, x2, y2, x3, y3)
print("%.3f %.3f %.3f" % (circle.x, circle.y, circle.r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s518087770 | p00010 | Accepted | n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
a = complex(x1, y1)
b = complex(x2, y2)
c = complex(x3, y3)
a -= c
b -= c
z0 = abs(a)**2 * b - abs(b)**2 * a
z0 /= a.conjugate() * b - a * b.conjugate()
z = z0 + c
zx = "{0:.3f}".format(z.real)
zy = "{0:.3f}".format(z.imag)
r = "{0:.3f}".format(abs(z0))
print(zx, zy, r)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s590285760 | p00010 | Accepted | import math
n = int(input())
round = lambda x:(x*1000*2+1)//2/1000
for i in range(n):
x1,y1,x2,y2,x3,y3 = [ float(s) for s in input().split() ]
r1 = x1*x1 + y1*y1
r2 = x2*x2 + y2*y2
r3 = x3*x3 + y3*y3
x1_x2 = x1 - x2
y1_y2 = y1 - y2
x1_x3 = x1 - x3
y1_y3 = y1 - y3
r1_r2 = r1 - r2
r1_r3 = r1 - r3
if x1_x2 == 0:
py = r1_r2 / (2*y1_y2)
px = (r1_r3 - 2*y1_y3*py) / (2*x1_x3)
else:
py = (r1_r2 * x1_x3 - r1_r3 * x1_x2) / (2*(y1_y2 * x1_x3 - y1_y3 * x1_x2))
px = (r1_r2 - 2*y1_y2*py) / (2*x1_x2)
r = math.sqrt((x1-px)**2 + (y1-py)**2)
print('{:.3f}'.format(0+px),'{:.3f}'.format(0+py),'{:.3f}'.format(0+round(r)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s810921843 | p00010 | Accepted | def solve():
from sys import stdin
f_i = stdin
n = int(f_i.readline())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, f_i.readline().split())
A = x1 + y1 * 1j
B = x2 + y2 * 1j
C = x3 + y3 * 1j
a = abs(C - B)
b = abs(A - C)
c = abs(B - A)
c1 = a**2 * (b**2 + c**2 - a**2)
c2 = b**2 * (c**2 + a**2 - b**2)
c3 = c**2 * (a**2 + b**2 - c**2)
U = (c1 * A + c2 * B + c3 * C) / (c1 + c2 + c3)
R = abs(U - A)
print('{:.3f} {:.3f} {:.3f}'.format(U.real, U.imag, R))
solve()
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s983247562 | p00010 | Accepted | n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
a = 2*(x1-x2)
b = 2*(y1-y2)
c = x1**2 - x2**2 + y1**2 - y2**2
d = 2*(x1-x3)
e = 2*(y1-y3)
f = x1**2 - x3**2 + y1**2 - y3**2
y = (c*d - a*f) / (b*d - a*e)
if a==0:
x = (f - e*y) / d
else:
x = (c - b*y) / a
r = ((x1 - x)**2 + (y1 - y)**2)**0.5
print('{:.3f}'.format(round(x, 3)), end=" ")
print('{:.3f}'.format(round(y, 3)), end=" ")
print('{:.3f}'.format(round(r, 3)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s253801764 | p00010 | Accepted | import math
n = int(input())
positions = []
for i in range(n):
positions.append(list(map(float, input().split())))
for i in range(n):
ra = [positions[i][0],positions[i][1]]
rb = [positions[i][2],positions[i][3]]
rc = [positions[i][4],positions[i][5]]
A = (rb[0]-rc[0])**2+(rb[1]-rc[1])**2
B = (rc[0]-ra[0])**2+(rc[1]-ra[1])**2
C = (ra[0]-rb[0])**2+(ra[1]-rb[1])**2
P = A * (B+C-A)
Q = B * (C+A-B)
R = C * (A+B-C)
rcc_x = (P*ra[0] + Q*rb[0] + R*rc[0]) / (P+Q+R)
rcc_y = (P*ra[1] + Q*rb[1] + R*rc[1]) / (P+Q+R)
radius = math.sqrt((rcc_x-positions[i][0])**2+(rcc_y-positions[i][1])**2)
print("{0:.3f} {1:.3f} {2:.3f}".format(rcc_x,rcc_y,radius))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s063542268 | p00010 | Accepted | import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s083090877 | p00010 | Accepted | 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))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s610729218 | p00010 | Accepted | import math
for _ in range(int(input())):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a,b,c=2*(x2-x1),2*(y2-y1),x1**2-x2**2+y1**2-y2**2
aa,bb,cc=2*(x3-x1),2*(y3-y1),x1**2-x3**2+y1**2-y3**2
x,y=(b*cc-bb*c)/(a*bb-aa*b),(c*aa-cc*a)/(a*bb-aa*b)
print('%.3f %.3f %.3f'%(x,y,math.hypot(x1-x,y1-y)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s024363287 | p00010 | Accepted | import sys,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*x1-x2*x2+y1*y1-y2*y2
a2=2*x3-2*x1
b2=2*y3-2*y1
c2=x1*x1-x3*x3+y1*y1-y3*y3
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)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s655021020 | p00010 | Accepted | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a=(x3-x1)*(x1**2+y1**2-x2**2-y2**2)-(x2-x1)*(x1**2+y1**2-x3**2-y3**2)
b=2*(x3-x1)*(y1-y2)-2*(x2-x1)*(y1-y3)
py=a/b
if x2-x1!=0:
px=(2*(y1-y2)*py-x1**2-y1**2+x2**2+y2**2)/(2*(x2-x1))
else:
px=(2*(y1-y3)*py-x1**2-y1**2+x3**2+y3**2)/(2*(x3-x1))
r=math.sqrt((px-x1)**2+(py-y1)**2)
print(f"{px:.3f}",f"{py:.3f}",f"{r:.3f}")
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s064594237 | p00010 | Accepted | import math
n = int(input())
positions = []
for i in range(n):
positions.append(list(map(float, input().split())))
for i in range(n):
ra = [positions[i][0],positions[i][1]]
rb = [positions[i][2],positions[i][3]]
rc = [positions[i][4],positions[i][5]]
A = (rb[0]-rc[0])**2+(rb[1]-rc[1])**2
B = (rc[0]-ra[0])**2+(rc[1]-ra[1])**2
C = (ra[0]-rb[0])**2+(ra[1]-rb[1])**2
P = A * (B+C-A)
Q = B * (C+A-B)
R = C * (A+B-C)
rcc_x = (P*ra[0] + Q*rb[0] + R*rc[0]) / (P+Q+R)
rcc_y = (P*ra[1] + Q*rb[1] + R*rc[1]) / (P+Q+R)
radius = math.sqrt((rcc_x-positions[i][0])**2+(rcc_y-positions[i][1])**2)
print("{0:.3f} {1:.3f} {2:.3f}".format(rcc_x,rcc_y,radius))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s405716502 | p00010 | Accepted | from decimal import Decimal, ROUND_HALF_UP
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,input().split())
a=2*(x1-x2)
b=2*(y1-y2)
c=x1**2+y1**2-x2**2-y2**2
d=2*(x1-x3)
e=2*(y1-y3)
f=x1**2+y1**2-x3**2-y3**2
x=(c*e-b*f)/(a*e-b*d)+0.0
y=(c*d-a*f)/(b*d-a*e)+0.0
r=((x-x1)**2+(y-y1)**2)**0.5
print(Decimal(str(x)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(y)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(r)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s214732147 | p00010 | Accepted | n = int(input())
import math
for _ in range(n):
ax,ay,bx,by,cx,cy = [float(i) for i in input().split()]
ab = math.sqrt((ax-bx)**2+(ay-by)**2)
bc = math.sqrt((bx-cx)**2+(by-cy)**2)
ca = math.sqrt((cx-ax)**2+(cy-ay)**2)
cos_a = (ab**2+ca**2-bc**2)/(2*ab*ca)
sin_a = math.sqrt(1-cos_a**2)
r = bc/(2*sin_a)
px = ((ay-cy)*(ay**2 -by**2 +ax**2 -bx**2) -(ay-by)*(ay**2 -cy**2 +ax**2 -cx**2)) / (2*(ay-cy)*(ax-bx)-2*(ay-by)*(ax-cx))
py = ((ax-cx)*(ax**2 -bx**2 +ay**2 -by**2) -(ax-bx)*(ax**2 -cx**2 +ay**2 -cy**2)) / (2*(ax-cx)*(ay-by)-2*(ax-bx)*(ay-cy))
def round3(x):
x_ = x*10**3
if x_%1 < 0.5:
x_ = math.floor(x_)
else:
x_ = math.ceil(x_)
return x_*10**(-3)
print("{:.3f} {:.3f} {:.3f}".format(round3(px),round3(py),round3(r)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s460477095 | p00010 | Accepted | import math
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a2 = (x2-x3)**2 + (y2-y3)**2
b2 = (x1-x3)**2 + (y1-y3)**2
c2 = (x1-x2)**2 + (y1-y2)**2
area = ((x2-x1) * (y3-y1) - (x3-x1) * (y2-y1)) / 2
x = (a2*(b2+c2-a2)*x1 + b2*(c2+a2-b2) *
x2 + c2*(a2+b2-c2)*x3) / (16*area*area)
y = (a2*(b2+c2-a2)*y1 + b2*(c2+a2-b2) *
y2 + c2*(a2+b2-c2)*y3) / (16*area*area)
r = ((x1-x)**2 + (y1-y)**2)**0.5
x = Decimal(str(x)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
y = Decimal(str(y)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
r = Decimal(str(r)).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
print(x, y, r)
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s889700742 | p00010 | Accepted | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def distance(x1, y1, x2, y2):
return math.sqrt((x1-x2)**2 + (y1-y2)**2)
def intersection(a1, a2, b1, b2):
x1,y1 = a1
x2,y2 = a2
x3,y3 = b1
x4,y4 = b2
ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1)
eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1)
delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)
if delta == 0:
return None
ramda = ksi / delta;
mu = eta / delta;
if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1:
return (x1 + ramda * (x2 - x1), y1 + ramda * (y2 - y1))
return None
def circumcenters(a,b,c):
t1 = [(a[0]+b[0])/2, (a[1]+b[1])/2]
s1 = [t1[1]-a[1], a[0]-t1[0]]
t2 = [(a[0]+c[0])/2, (a[1]+c[1])/2]
s2 = [t2[1]-a[1], a[0]-t2[0]]
p1 = [t1[0]+s1[0]*1e7, t1[1]+s1[1]*1e7]
p2 = [t1[0]-s1[0]*1e7, t1[1]-s1[1]*1e7]
p3 = [t2[0]+s2[0]*1e7, t2[1]+s2[1]*1e7]
p4 = [t2[0]-s2[0]*1e7, t2[1]-s2[1]*1e7]
return intersection(p1,p2,p3,p4)
def main():
n = I()
rr = []
for _ in range(n):
x1,y1,x2,y2,x3,y3 = LF()
a = [x1,y1]
b = [x2,y2]
c = [x3,y3]
t = circumcenters(a,b,c)
rr.append('{:0.3f} {:0.3f} {:0.3f}'.format(t[0], t[1], distance(t[0],t[1],x1,y1)))
return '\n'.join(rr)
print(main())
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s685092580 | p00010 | Accepted | n = int(input())
for _ in range(n):
x1,y1,x2,y2,x3,y3 = map(float, input().split())
gx = (x1+x2+x3)/3
gy = (y1+y2+y3)/3
G=( y2*x1-y1*x2 +y3*x2-y2*x3 +y1*x3-y3*x1 )
Xc= ((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(2*G)
Yc=-((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(2*G)
r = ( (x1 - Xc) * (x1 - Xc) + (y1 - Yc) * (y1 - Yc) )**0.5
print("%.3f %.3f %.3f"%(Xc,Yc,r))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s492145493 | p00010 | Accepted | def circumcenter(vert1, vert2, vert3):
# H/T: wikipedia.org/wiki/Circumscribed_circle
# refer from https://gist.github.com/dhermes/9ce057da49df63345c33
Ax, Ay = vert1
Bx, By = vert2
Cx, Cy = vert3
D = 2 * (Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By))
norm_A = Ax**2 + Ay**2
norm_B = Bx**2 + By**2
norm_C = Cx**2 + Cy**2
Ux = norm_A * (By - Cy) + norm_B * (Cy - Ay) + norm_C * (Ay - By)
Uy = -(norm_A * (Bx - Cx) + norm_B * (Cx - Ax) + norm_C * (Ax - Bx))
r = (Ax - Ux/D)*(Ax - Ux/D) + (Ay - Uy/D)* (Ay - Uy/D)
r = float(r)**0.5
return [Ux/D, Uy/D, r]
n = int(input())
for i in range(n):
xs = list(map(float, input().split()))
a = circumcenter(xs[0:2], xs[2:4], xs[4:6])
print(' '.join(map(lambda x:f'{x:0.03f}', a)))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s545516481 | p00010 | Accepted | n = int(input())
ans = []
for i in range(n):
ax,ay,bx,by,cx,cy = map(float, input().split(" "))
a,b,c = 2*(ax-bx),2*(ay-by),(ax+bx)*(ax-bx)+(ay+by)*(ay-by)
d,e,f = 2*(ax-cx),2*(ay-cy),(ax+cx)*(ax-cx)+(ay+cy)*(ay-cy)
det = a*e-b*d
px = (c*e-b*f)/det
py = (a*f-c*d)/det
if abs(px) < 1e-4:
px = 0.0
if abs(py) < 1e-4:
py = 0.0
r = ((ax-px)**2+(ay-py)**2)**(1/2)
ans.append([px,py,r])
for i in range(n):
print("{0:.3f}".format(ans[i][0]),"{0:.3f}".format(ans[i][1]),"{0:.3f}".format(ans[i][2]))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s412598109 | p00010 | Accepted | # 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))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s648969203 | p00010 | Runtime Error | import math
def run():
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
u1 = (x1-x3)*(x2-x1)*(x3-x2)
u2 = (x2-x1)*(y3-y2)*(y3+y2)
u3 = (x3-x2)*(y2-y1)*(y2+y1)
v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
Py = (-u1 + u2 - u3) / v / 2
Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / (x2-x1) / 2
r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))
if __name__ == '__main__':
run()
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s701534005 | p00010 | Runtime Error | #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>
using namespace std;
#define reep(i, f, n) for (int i = f; i < n; ++i)
#define rep(i, n) reep(i, 0, n)
int main(){
float x1,x2,x3,y1,y2,y3,gx,gy,G,Xc,Yc,r;
int n;
scanf("%d", &n);
for (int i=0;i<n;i++) {
scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
gx = (x1+x2+x3)/3;
gy = (y1+y2+y3)/3;
G =( y2*x1-y1*x2 +y3*x2-y2*x3 +y1*x3-y3*x1 );
Xc = ((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(2*G);
Yc =-((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(2*G);
r = sqrt( (x1 - Xc) * (x1 - Xc) + (y1 - Yc) * (y1 - Yc) );
printf("%.3f %.3f %.3f\n", Xc, Yc, r);
}
return EXIT_SUCCESS;
}
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s521544017 | p00010 | Runtime Error | 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
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
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())) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s065758709 | p00010 | Runtime Error | # -*- 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
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
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())) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s557884869 | p00010 | Runtime Error | # -*- 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())) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s988774061 | p00010 | Runtime Error | # 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 | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s911095464 | p00010 | Runtime Error | 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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s314705763 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s508923881 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s585418388 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s784666888 | p00010 | Runtime Error | #!/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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s322827297 | p00010 | Runtime Error | # 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s955385463 | p00010 | Runtime Error | 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))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s748816088 | p00010 | Runtime Error | 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])) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s564589367 | p00010 | Runtime Error | 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))) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s745746882 | p00010 | Runtime Error | 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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s465297109 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s976251197 | p00010 | Runtime Error | 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) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s518084268 | p00010 | Runtime Error | 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))
| 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
s841143812 | p00010 | Runtime Error | 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)) | 1
0.0 0.0 2.0 0.0 2.0 2.0
| 1.000 1.000 1.414
|
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<H1>Circumscribed Circle of A Triangle.</H1>
<p>
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.
</p>
<H2>Input</H2>
<p>
Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:<br/>
<br/>
$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$<br/>
<br/>
in a line. All the input are real numbers.
</p>
<H2>Output</H2>
<p>
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.
</p>
<h2>Constraints</h2>
<ul>
<li>$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$</li>
<li>$ n \leq 20$</li>
</ul>
<H2>Sample Input</H2>
<pre>
1
0.0 0.0 2.0 0.0 2.0 2.0
</pre>
<H2>Output for the Sample Input</H2>
<pre>
1.000 1.000 1.414
</pre>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.