submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s070329461 | p00010 | Wrong Answer | def main():
import math
n = int(input())
w = [0]*6
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
w[0] = 2*(x2-x1)
w[1] = 2*(y2-y1)
w[2] = x2**2 + y2**2 - x1**2 - y1**2
w[3] = 2*(x3-x1)
w[4] = 2*(y3-y1)
w[5] = x3**2 + y3**2 - x1**2 - y1**2
x, y = solve(w)
r = math.sqrt((x-x1)**2 + (y-y1)**2)
print(x, y, "{:.3f}".format(r))
def solve(w):
x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
x = round(x, 3)
y = round(y, 3)
if x == -0.0:
x = 0.0
if y == -0.0:
y = 0.0
return x, y
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>
|
s962337729 | p00010 | Wrong Answer | def main():
import math
n = int(input())
w = [0]*6
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
w[0] = 2*(x2-x1)
w[1] = 2*(y2-y1)
w[2] = x2**2 + y2**2 - x1**2 - y1**2
w[3] = 2*(x3-x1)
w[4] = 2*(y3-y1)
w[5] = x3**2 + y3**2 - x1**2 - y1**2
x, y = solve(w)
r = math.sqrt((x-x1)**2 + (y-y1)**2)
print("{:.3f} {:.3f} {:.3f}".format(x, y, r))
def solve(w):
x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
x = round(x, 3)
y = round(y, 3)
if x == -0.0:
x = 0.0
if y == -0.0:
y = 0.0
return x, y
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>
|
s129473068 | p00010 | Wrong Answer | def main():
import math
n = int(input())
w = [0]*6
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
w[0] = 2*(x2-x1)
w[1] = 2*(y2-y1)
w[2] = x1**2 + y1**2 - x2**2 - y2**2
w[3] = 2*(x3-x1)
w[4] = 2*(y3-y1)
w[5] = x1**2 + y1**2 - x3**2 - y3**2
x, y = solve(w)
r = math.hypot((x-x1), (y-y1))
print("{:.3f} {:.3f} {:.3f}".format(x, y, r))
def solve(w):
x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
x = round(x, 3)
y = round(y, 3)
if x == -0.0:
x = 0.0
if y == -0.0:
y = 0.0
return x, y
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>
|
s000108724 | p00010 | Wrong Answer | # coding: utf-8
import math
n = int(raw_input())
for i in range(n):
data = map(float, raw_input().split())
x1 = data[0]
y1 = data[1]
x2 = data[2]
y2 = data[3]
x3 = data[4]
y3 = data[5]
k = 0.5 * ( (x3-x2)*(x3-x1) + (y3-y2)*(y3-y1) ) / ( (x2-x1)*(y3-y1) + (y2-y1)*(x3-x1) )
x = 0.5 * (x1 + x2) - k * (y2 - y1)
y = 0.5 * (y1 + y2) + k * (x2 - x1)
r = math.sqrt( (x-x1)**2 + (y-y1)**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>
|
s460661171 | p00010 | Wrong Answer | 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+a*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)),
print ('%.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>
|
s502413873 | p00010 | Wrong Answer | 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-d)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")
| 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>
|
s263621528 | p00010 | Wrong Answer | 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:.4} {y:.4} {(x*x+y*y)**.5:.4}")
| 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>
|
s551282367 | p00010 | Wrong Answer | 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*x+y*y)**.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>
|
s872531778 | p00010 | Wrong Answer | import math
def length(ax, ay, bx, by):
return math.sqrt((ax - bx)**2 + (ay - by)**2)
n = int(input())
for i in range(n):
ax, ay, bx, by, cx, cy = map(float, input().split())
ab = length(ax, ay, bx, by)
bc = length(bx, by, cx, cy)
ca = length(cx, cy, ax, ay)
s = (ab + bc + ca) / 2.0
area = math.sqrt(s * (s - ab) * (s - bc) * (s - ca))
sinA = area * 2.0 / bc
angleB = math.asin(sinA / ab)
angleC = math.asin(sinA / ca)
angleA = math.pi - angleB - angleC
sin2A = math.sin(2.0 * angleA)
sin2B = math.sin(2.0 * angleB)
sin2C = math.sin(2.0 * angleC)
# 外心の計算
center_x = (ax * sin2A + bx * sin2B + cx * sin2C) / (sin2A + sin2B + sin2C)
center_y = (ay * sin2A + by * sin2B + cy * sin2C) / (sin2A + sin2B + sin2C)
# 半径の計算
radius = bc / math.sin(angleA) / 2.0
print("{0:.3f} {1:.3f} {2:.3f}".format(center_x, center_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>
|
s635606354 | p00010 | Wrong Answer | from math import hypot
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,input().split())
x4=((y1-y3)*(y1**2-y2**2+x1**2-x2**2)-(y1-y2)*(y1**2-y3**2+x1**2-x3**2))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3))
y4=((x1-x3)*(x1**2-x2**2+y1**2-x1**2)-(x1-x2)*(x1**2-x3**2+y1**2-y3**2))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3))
r=hypot(x1-x4,y1-y4)
print("{:.3f} {:.3f} {:.3f}".format(x4,y4,r))
| 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>
|
s168183605 | p00010 | Wrong Answer | 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("{:.4f} {:.4f} {:.4f}".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>
|
s700979052 | p00010 | Wrong Answer | 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("{:.4f} {:.4f} {:.4f}".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>
|
s528107308 | p00010 | Wrong Answer | # -*- 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)
print(tmp)
x = -tmp[0]/2
y = -tmp[1]/2
r = sqrt((tmp[0]**2 + tmp[1]**2 - 4*tmp[2])/4)
print('{:.3} {:.3} {:.3}'.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>
|
s300277009 | p00010 | Wrong Answer | from math import sqrt
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)
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>
|
s282324045 | p00010 | Wrong Answer | from math import sqrt
def g(x):
y = (((1000 * x) * 2 + 1) // 2) / 1000
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))
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>
|
s501660483 | p00010 | Wrong Answer | from math import *
def g(x):
y = (((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))
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>
|
s083502886 | p00010 | Wrong Answer | 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))
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>
|
s067799414 | p00010 | Wrong Answer | #!/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 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 = "{0:.3f}".format(g(X))
Y = "{0:.3f}".format(g(Y))
R = "{0:.3f}".format(g(R))
if X == "-0.000" or Y == "-0.000" or R == "-0.000":
while True:
X += 0
print(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>
|
s649294635 | p00010 | Wrong Answer | #!/usr/bin/env python
from math import *
def g(x):
y = (int((1000 * abs(x)) * 2 + 1) // 2) / 1000
return y / abs(y) * 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>
|
s921134861 | p00010 | Wrong Answer | 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*10000+5)/10000, (y*10000+5)/10000, (r*10000+5)/10000]
#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>
|
s995913392 | p00010 | Wrong Answer | #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>
|
s733879880 | p00010 | Wrong Answer | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
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 = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
(l3**2 + l1**2 - l2**2)*l2*x2**2 +\
(l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
(l3**2 + l1**2 - l2**2)*l2*y2**2 +\
(l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
r = ((px-x1)**2+(py-y1)**2)**0.5
print 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>
|
s251669418 | p00010 | Wrong Answer | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
n = input()
ans = []
while True:
try:
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 = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
(l3**2 + l1**2 - l2**2)*l2*x2**2 +\
(l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
(l3**2 + l1**2 - l2**2)*l2*y2**2 +\
(l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
r = ((px-x1)**2+(py-y1)**2)**0.5
ans.append([px,py,r])
for an in ans:
print an[0],an[1],an[2]
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>
|
s590903225 | p00010 | Wrong Answer | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
n = input()
ans = []
while True:
try:
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 = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
(l3**2 + l1**2 - l2**2)*l2*x2**2 +\
(l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
(l3**2 + l1**2 - l2**2)*l2*y2**2 +\
(l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
r = ((px-x1)**2+(py-y1)**2)**0.5
ans.append([px,py,r])
for an in ans:
print '%.3f %.3f %.3f ' % (an[0],an[1],an[2])
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>
|
s217296760 | p00010 | Wrong Answer | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
n = input()
ans = []
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 = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
(l3**2 + l1**2 - l2**2)*l2*x2**2 +\
(l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
(l3**2 + l1**2 - l2**2)*l2*y2**2 +\
(l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
r = ((px-x1)**2+(py-y1)**2)**0.5
ans.append([px,py,r])
for an in ans:
print '%.3f %.3f %.3f ' % (an[0],an[1],an[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>
|
s140612670 | p00010 | Wrong Answer | def heron(a,b,c):
s = 0.5*(a+b+c)
return (s*(s-a)*(s-b)*(s-c))**0.5
n = input()
ans = []
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 = ((l2**2 + l3**2 - l1**2)*l1*x1**2 +\
(l3**2 + l1**2 - l2**2)*l2*x2**2 +\
(l1**2 + l2**2 - l3**2)*l3*x3**2)/(16*S**2)
py = ((l2**2 + l3**2 - l1**2)*l1*y1**2 +\
(l3**2 + l1**2 - l2**2)*l2*y2**2 +\
(l1**2 + l2**2 - l3**2)*l3*y3**2)/(16*S**2)
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>
|
s548677464 | p00010 | Wrong Answer | import math
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = 2*(x[0]-x[2])
b = 2*(x[1]-x[3])
c = (x[1]**2-x[2]**2)-(x[1]**2-x[3]**2)
d = 2*(x[0]-x[4])
e = 2*(x[1]-x[5])
f = (x[1]**2-x[4]**2)-(x[1]**2-x[5]**2)
p = round((c*e-b*f)/(a*e-b*d),4)
q = round((a*f-c*d)/(a*e-b*d),4)
X = '%.3f' % p
Y = '%.3f' % q
if str(X) == '-0.000': X = '%.3f' % 0.000
if str(Y) == '-0.000': Y = '%.3f' % 0.000
r = (x[0]-float(X))**2+(x[1]-float(Y))**2
r = math.sqrt(r)
r = math.fabs(r)
r = round(r,4)
R = '%.3f' % r
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>
|
s919017155 | p00010 | Wrong Answer | import math
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = 2*(x[0]-x[2])
b = 2*(x[1]-x[3])
c = (x[1]**2-x[2]**2)+(x[1]**2-x[3]**2)
d = 2*(x[0]-x[4])
e = 2*(x[1]-x[5])
f = (x[1]**2-x[4]**2)+(x[1]**2-x[5]**2)
p = round((c*e-b*f)/(a*e-b*d),4)
q = round((a*f-c*d)/(a*e-b*d),4)
X = '%.3f' % p
Y = '%.3f' % q
if str(X) == '-0.000': X = '%.3f' % 0.000
if str(Y) == '-0.000': Y = '%.3f' % 0.000
r = (x[0]-float(X))**2+(x[1]-float(Y))**2
r = math.sqrt(r)
r = math.fabs(r)
r = round(r,4)
R = '%.3f' % r
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>
|
s307567897 | p00010 | Wrong Answer | import math
import decimal
for val in xrange(0,input()):
x = map(float,raw_input().split(' '))
a = decimal.Decimal(2*(x[0]-x[2]))
b = decimal.Decimal(2*(x[1]-x[3]))
c = decimal.Decimal((x[1]**2-x[2]**2)+(x[1]**2-x[3]**2))
d = decimal.Decimal(2*(x[0]-x[4]))
e = decimal.Decimal(2*(x[1]-x[5]))
f = decimal.Decimal((x[1]**2-x[4]**2)+(x[1]**2-x[5]**2))
p = decimal.Decimal(round((c*e-b*f)/(a*e-b*d),4))
q = decimal.Decimal(round((a*f-c*d)/(a*e-b*d),4))
X = '%.3f' % p
Y = '%.3f' % q
if str(X) == '-0.000': X = '%.3f' % 0.000
if str(Y) == '-0.000': Y = '%.3f' % 0.000
r = decimal.Decimal((x[0]-float(X))**2+(x[1]-float(Y))**2)
r = math.sqrt(r)
r = math.fabs(r)
r = round(r,4)
R = '%.3f' % r
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>
|
s205815818 | p00010 | Wrong Answer |
import sys
import math
def solv(x1, y1, x2, y2, x3, y3):
if y2 == y1:
xp = 0.5 * (x1 + x2)
yp = (x3 - x1)/(y3 - y1) * xp + 0.5 * (y1 + y3 - (x3**2 - x1**2)/(y3 - y1))
elif y3 == y1:
xp = 0.5 * (x1 + x3)
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
else:
xp = 0.5 * (y3 - y2 - (x3**2 - x1**2)/(y3 - y1) + (x2**2 - x1**2)/(y2 - y1))/((x2 - x1)/(y2 - y1) - (x3 - x1)/(y3 - y1))
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
r = math.sqrt((x1 - xp)**2 + (y1 - yp)**2)
return (xp, yp, r)
#input_file = open(sys.argv[1], "r")
#lines = input_file.readlines()
lines = sys.stdin.readlines()
lines.pop(0)
for line in lines:
l = map((lambda x: float(x)), line.split(' '))
x1 = l[0]
y1 = l[1]
x2 = l[2]
y2 = l[3]
x3 = l[4]
y3 = l[5]
xp, yp, r = solv(x1, y1, x2, y2, x3, y3)
print("%5.3f %5.3f %5.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>
|
s198507202 | p00010 | Wrong Answer |
import sys
import math
def solv(x1, y1, x2, y2, x3, y3):
if y2 == y1:
xp = 0.5 * (x1 + x2)
yp = (x3 - x1)/(y3 - y1) * xp + 0.5 * (y1 + y3 - (x3**2 - x1**2)/(y3 - y1))
elif y3 == y1:
xp = 0.5 * (x1 + x3)
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
else:
xp = 0.5 * (y3 - y2 - (x3**2 - x1**2)/(y3 - y1) + (x2**2 - x1**2)/(y2 - y1))/((x2 - x1)/(y2 - y1) - (x3 - x1)/(y3 - y1))
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
r = math.sqrt((x1 - xp)**2 + (y1 - yp)**2)
return (xp, yp, r)
#input_file = open(sys.argv[1], "r")
#lines = input_file.readlines()
lines = sys.stdin.readlines()
lines.pop(0)
for line in lines:
l = map((lambda x: float(x)), line.split(' '))
x1 = l[0]
y1 = l[1]
x2 = l[2]
y2 = l[3]
x3 = l[4]
y3 = l[5]
xp, yp, r = solv(x1, y1, x2, y2, x3, y3)
print("%5.3f %5.3f %5.3f" % (round(xp, 3), round(yp, 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>
|
s397340516 | p00010 | Wrong Answer |
import sys
import math
def solv(x1, y1, x2, y2, x3, y3):
if y2 == y1:
xp = 0.5 * (x1 + x2)
yp = (x3 - x1)/(y3 - y1) * xp + 0.5 * (y1 + y3 - (x3**2 - x1**2)/(y3 - y1))
elif y3 == y1:
xp = 0.5 * (x1 + x3)
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
elif y3 == y2:
xp = 0.5 * (x2 + x3)
yp = (x2 - x2)/(y1 - y2) * xp + 0.5 * (y2 + y1 - (x1**2 - x2**2)/(y1 - y2))
else:
xp = 0.5 * (y3 - y2 - (x3**2 - x1**2)/(y3 - y1) + (x2**2 - x1**2)/(y2 - y1))/((x2 - x1)/(y2 - y1) - (x3 - x1)/(y3 - y1))
yp = (x2 - x1)/(y2 - y1) * xp + 0.5 * (y1 + y2 - (x2**2 - x1**2)/(y2 - y1))
r = math.sqrt((x1 - xp)**2 + (y1 - yp)**2)
return (xp, yp, r)
#input_file = open(sys.argv[1], "r")
#lines = input_file.readlines()
lines = sys.stdin.readlines()
lines.pop(0)
for line in lines:
l = map(float, line.split(' '))
x1 = l[0]
y1 = l[1]
x2 = l[2]
y2 = l[3]
x3 = l[4]
y3 = l[5]
xp, yp, r = solv(x1, y1, x2, y2, x3, y3)
print("%5.3f %5.3f %5.3f" % (round(xp, 3), round(yp, 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>
|
s376108372 | p00010 | Wrong Answer | import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.c = math.hypot(x1 - x2, y1 - y2)
self.a = math.hypot(x2 - x3, y2 - y3)
self.b = math.hypot(x3 - x1, y3 - y1)
print self.a
print self.b
print self.c
self.degreeA = math.acos((self.b ** 2 + self.c ** 2 - self.a ** 2) / (2 * self.b * self.c))
self.degreeB = math.acos((self.c ** 2 + self.a ** 2 - self.b ** 2) / (2 * self.c * self.a))
self.degreeC = math.acos((self.a ** 2 + self.b ** 2 - self.c ** 2) / (2 * self.a * self.b))
def circumscribedCircleRadius(self):
return self.a / math.sin(self.degreeA) / 2.0
def circumscribedCircleX(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.x1 * A + self.x2 * B + self.x3 * C) / (A + B + C)
n = input()
for t in range(n):
data = map(float, raw_input().split())
t = Triangle(data[0], data[1], data[2], data[3], data[4], data[5])
print "%.3f %.3f" % (round(t.circumscribedCircleRadius(),4), round(t.circumscribedCircleRadius(), 4)) | 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>
|
s954133637 | p00010 | Wrong Answer | import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.c = math.hypot(x1 - x2, y1 - y2)
self.a = math.hypot(x2 - x3, y2 - y3)
self.b = math.hypot(x3 - x1, y3 - y1)
print self.a
print self.b
print self.c
self.degreeA = math.acos((self.b ** 2 + self.c ** 2 - self.a ** 2) / (2 * self.b * self.c))
self.degreeB = math.acos((self.c ** 2 + self.a ** 2 - self.b ** 2) / (2 * self.c * self.a))
self.degreeC = math.acos((self.a ** 2 + self.b ** 2 - self.c ** 2) / (2 * self.a * self.b))
def circumscribedCircleRadius(self):
return self.a / math.sin(self.degreeA) / 2.0
def circumscribedCircleX(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.x1 * A + self.x2 * B + self.x3 * C) / (A + B + C)
def circumscribedCircleY(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.y1 * A + self.y2 * B + self.y3 * C) / (A + B + C)
n = input()
for t in range(n):
data = map(float, raw_input().split())
t = Triangle(data[0], data[1], data[2], data[3], data[4], data[5])
print "%.3f %.3f %.3f" % (round(t.circumscribedCircleX(),4),
round(t.circumscribedCircleY(),4),
round(t.circumscribedCircleRadius(), 4)) | 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>
|
s513993989 | p00010 | Wrong Answer | import math
class Triangle:
def __init__(self, x1, y1, x2, y2, x3, y3):
self.x1 = x1
self.x2 = x2
self.x3 = x3
self.y1 = y1
self.y2 = y2
self.y3 = y3
self.c = math.hypot(x1 - x2, y1 - y2)
self.a = math.hypot(x2 - x3, y2 - y3)
self.b = math.hypot(x3 - x1, y3 - y1)
self.degreeA = math.acos((self.b ** 2 + self.c ** 2 - self.a ** 2) / (2 * self.b * self.c))
self.degreeB = math.acos((self.c ** 2 + self.a ** 2 - self.b ** 2) / (2 * self.c * self.a))
self.degreeC = math.acos((self.a ** 2 + self.b ** 2 - self.c ** 2) / (2 * self.a * self.b))
def circumscribedCircleRadius(self):
return self.a / math.sin(self.degreeA) / 2.0
def circumscribedCircleX(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.x1 * A + self.x2 * B + self.x3 * C) / (A + B + C)
def circumscribedCircleY(self):
A = math.sin(2.0 * self.degreeA)
B = math.sin(2.0 * self.degreeB)
C = math.sin(2.0 * self.degreeC)
return (self.y1 * A + self.y2 * B + self.y3 * C) / (A + B + C)
n = input()
for t in range(n):
data = map(float, raw_input().split())
t = Triangle(data[0], data[1], data[2], data[3], data[4], data[5])
print "%.3f %.3f %.3f" % (round(t.circumscribedCircleX(),4),
round(t.circumscribedCircleY(),4),
round(t.circumscribedCircleRadius(), 4)) | 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>
|
s115477747 | p00010 | Wrong Answer | 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
def f003():
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
return x0,y0,r
x0,y0,r = f003()
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>
|
s518605171 | p00010 | Wrong Answer | import math
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>
|
s419613259 | p00010 | Wrong Answer | import math
def get_center(x1, y1, x2, y2, x3, 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 - y2**2
x = (b1*c2 -b2*c1)/(a1*b2 - a2*b1)
y = (c1*a2 -c2*a1)/(a1*b2 - a2*b1)
return x, y
def get_length(x1, y1, x2, y2, x3, y3):
a = math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))
b = math.sqrt((x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3))
c = math.sqrt((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1))
return a, b, c
def get_radius(x1, y1, x2, y2, x3, y3):
a, b, c = get_length(x1, y1, x2, y2, x3, y3)
s = (a + b + c)/2.0
area = math.sqrt(s*(s-a)*(s-b)*(s-c))
return (a*b*c)/(4.0*area)
n = int(raw_input())
for i in range(0, n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
r = get_radius(x1, y1, x2, y2, x3, y3)
cx, cy = get_center(x1, y1, x2, y2, x3, y3)
print '%.3f %.3f %.3f'%(cx, cy, 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>
|
s632738969 | p00010 | Wrong Answer | import math
def get_center(x1, y1, x2, y2, x3, 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 - y2**2
x = (b1*c2 -b2*c1)/(a1*b2 - a2*b1)
y = (c1*a2 -c2*a1)/(a1*b2 - a2*b1)
return x, y
def get_length(x1, y1, x2, y2, x3, y3):
a = math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))
b = math.sqrt((x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3))
c = math.sqrt((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1))
return a, b, c
def get_radius(x1, y1, x2, y2, x3, y3):
a, b, c = get_length(x1, y1, x2, y2, x3, y3)
s = (a + b + c)/2.0
area = math.sqrt(s*(s-a)*(s-b)*(s-c))
return (a*b*c)/(4.0*area)
n = int(raw_input())
for i in range(0, n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
r = get_radius(x1, y1, x2, y2, x3, y3)
cx, cy = get_center(x1, y1, x2, y2, x3, y3)
print '%.3f %.3f %.3f'%(round(cx,4), round(cy, 4), round(r, 4)) | 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>
|
s707025188 | p00010 | Accepted | import math
class P(object):
def __init__(self, x, y):
self.x = x
self.y = y
def width(self, p):
return math.sqrt((self.x - p.x)**2 + (self.y - p.y)**2)
def __repr__(self):
return '{0:.3f} {1:.3f}'.format(self.x, self.y)
def calc_cos(a,b,c):
return (b**2 + c**2 - a**2) / (2*b*c)
def calc_sin(c):
return math.sqrt(1 - c**2)
def calc_2sin(s,c):
return 2 * s * c
def run():
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
p1, p2, p3 = P(x1, y1), P(x2, y2), P(x3, y3)
a, b, c = p1.width(p2), p2.width(p3), p3.width(p1)
cosA, cosB, cosC = calc_cos(a,b,c), calc_cos(b,c,a), calc_cos(c,a,b)
sinA, sinB, sinC = calc_sin(cosA), calc_sin(cosB), calc_sin(cosC)
sin2A, sin2B, sin2C = calc_2sin(sinA, cosA), calc_2sin(sinB, cosB), calc_2sin(sinC, cosC)
r = a / sinA / 2
x = (p1.x * sin2B + p2.x * sin2C + p3.x * sin2A) / (sin2A + sin2B + sin2C)
y = (p1.y * sin2B + p2.y * sin2C + p3.y * sin2A) / (sin2A + sin2B + sin2C)
print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,r))
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>
|
s888023198 | p00010 | Accepted | # -*- 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)
n = int(input())
for i in range(n):
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:.3f} {1:.3f} {2:.3f}".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>
|
s693920046 | p00010 | Accepted | import math
n = input()
for i in range(n):
p = map(float, raw_input().split())
x1, y1, x2, y2, x3, y3 = p[0], p[1], p[2], p[3], p[4], p[5]
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 = math.sqrt((x1 - px)**2 + (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>
|
s031239253 | p00010 | Accepted | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def calc_det(lis):
return lis[0]*lis[3]-lis[1]*lis[2]
def sq(x):
return x*x
for s in sys.stdin:
d = map(float, s.split() )
if len(d) == 1:
continue
x1,y1,x2,y2,x3,y3 = d[0],d[1],d[2],d[3],d[4],d[5]
d11 = 2*(x3-x2)
d12 = 2*(y3-y2)
d21 = 2*(x2-x1)
d22 = 2*(y2-y1)
x11 = sq(x3)-sq(x2)+sq(y3)-sq(y2)
x21 = sq(x2)-sq(x1)+sq(y2)-sq(y1)
y12 = x11
y22 = x21
x0 = calc_det( [x11,d12,x21,d22] )/calc_det( [d11,d12,d21,d22] )
y0 = calc_det( [d11,y12,d21,y22] )/calc_det( [d11,d12,d21,d22] )
r = ( (x0-x1)**2 + (y0-y1)**2 )**0.5
print "%.3f %.3f %.3f" % (x0,y0,r)
'''
Bibliography
3点を通る円の半径を求む(#7)
http://www.geocities.jp/jtqsw192/FIG/313r/3point_r.htm
''' | 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>
|
s889427989 | p00010 | Accepted | import sys
f = sys.stdin
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>
|
s351931260 | p00010 | Accepted | 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.0
a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
else:
a1=-(x2-x1)/(y2-y1)
b1=((y2+y1)-a1*(x1+x2))/2.0
a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
else:
a1=-(x2-x1)/(y2-y1)
a2=-(x3-x1)/(y3-y1)
b1=((y2+y1)-a1*(x1+x2))/2.0
b2=((y3+y1)-a2*(x1+x3))/2.0
a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,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>
|
s580932409 | p00010 | Accepted | # coding: utf-8
import math
for i in range(int(raw_input())):
x1, y1, x2, y2, x3, y3 = map(float,raw_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 = math.sqrt((x1-px)**2 + (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>
|
s989196126 | p00010 | Accepted | def calc(l):
A1=2*(l[1][0]-l[0][0])
B1=2*(l[1][1]-l[0][1])
C1=l[0][0]**2-l[1][0]**2+l[0][1]**2-l[1][1]**2
A2=2*(l[2][0]-l[0][0])
B2=2*(l[2][1]-l[0][1])
C2=l[0][0]**2-l[2][0]**2+l[0][1]**2-l[2][1]**2
X=(B1*C2-B2*C1)/(A1*B2-A2*B1)
Y=(C1*A2-C2*A1)/(A1*B2-A2*B1)
R=((X-l[0][0])**2+(Y-l[0][1])**2)**0.5
return tuple(map(round, [X,Y,R], [3]*3))
l=[zip(*[iter(map(float,raw_input().split()))]*2) for i in range(input())]
for ll in l:
print "%.3f %.3f %.3f"%(calc(ll)) | 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>
|
s090858081 | p00010 | Accepted | def calc(a,b,c,d,e,f):
A1=2*(c-a)
B1=2*(d-b)
C1=a**2-c**2+b**2-d**2
A2=2*(e-a)
B2=2*(f-b)
C2=a*a-e*e+b*b-f*f
X=(B1*C2-B2*C1)/(A1*B2-A2*B1)
Y=(C1*A2-C2*A1)/(A1*B2-A2*B1)
R=((X-a)**2+(Y-b)**2)**0.5
return tuple(map(round, [X,Y,R], [3]*3))
l=[map(float,raw_input().split()) for i in range(input())]
for ll in l:
print "%.3f %.3f %.3f"%(calc(*ll)) | 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>
|
s386023601 | p00010 | Accepted | def calc(a,b,c,d,e,f):
A=2*(c-a)
B=2*(d-b)
C=a*a-c*c+b*b-d*d
D=2*(e-a)
E=2*(f-b)
F=a*a-e*e+b*b-f*f
N=(A*E-D*B)
X=(B*F-E*C)/N
Y=(C*D-F*A)/N
R=((X-a)**2+(Y-b)**2)**0.5
return tuple(map(round,[X,Y,R],[3]*3))
l=[map(float,raw_input().split())for i in range(input())]
for k in l:print"%.3f %.3f %.3f"%(calc(*k)) | 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>
|
s122823497 | p00010 | Accepted | def calc(a,b,c,d,e,f):
A=2*(c-a)
B=2*(d-b)
C=a*a-c*c+b*b-d*d
D=2*(e-a)
E=2*(f-b)
F=a*a-e*e+b*b-f*f
N=(A*E-D*B)
X=(B*F-E*C)/N
Y=(C*D-F*A)/N
return tuple(map(round,[X,Y,((X-a)**2+(Y-b)**2)**0.5],[3]*3))
l=[map(float,raw_input().split())for i in range(input())]
for k in l:print"%.3f %.3f %.3f"%(calc(*k)) | 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>
|
s543355455 | p00010 | Accepted | def g(a,b,c,d,e,f):
A=2*(c-a)
B=2*(d-b)
C=a*a-c*c+b*b-d*d
D=2*(e-a)
E=2*(f-b)
F=a*a-e*e+b*b-f*f
N=(A*E-D*B)
X=(B*F-E*C)/N
Y=(C*D-F*A)/N
return tuple(map(round,[X,Y,((X-a)**2+(Y-b)**2)**0.5],[3]*3))
for k in [map(float,raw_input().split())for i in range(input())]:print"%.3f %.3f %.3f"%(g(*k)) | 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>
|
s152540471 | p00010 | Accepted | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
n = int(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>
|
s773101625 | p00010 | Accepted | # coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp
def __det(matrix):
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]
def __sqdist(p1,p2):
return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5
n = int(raw_input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
det = __det([[(x2-x1),(y2-y1)],[(x3-x1),(y3-y1)]])
c1 = (x1**2-x2**2+y1**2-y2**2)/2
c2 = (x1**2-x3**2+y1**2-y3**2)/2
px = __det([[c1,(y1-y2)],[c2,(y1-y3)]])/det
py = __det([[(x1-x2),c1],[(x1-x3),c2]])/det
r = __sqdist([x1,y1],[px,py])
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>
|
s040160979 | p00010 | Accepted | # coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp
def __det(matrix):
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]
def __sqdist(p1,p2):
return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**.5
n = int(raw_input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split(' '))
det = __det([[(x2-x1),(y2-y1)],[(x3-x1),(y3-y1)]])
c1 = (x2**2-x1**2+y2**2-y1**2)/2
c2 = (x3**2-x1**2+y3**2-y1**2)/2
px = __det([[c1,(y2-y1)],[c2,(y3-y1)]])/det
py = __det([[(x2-x1),c1],[(x3-x1),c2]])/det
r = __sqdist([x1,y1],[px,py])
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>
|
s182973471 | p00010 | Accepted | n=int(raw_input())
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x1-x3)**2+(y1-y3)**2)**0.5
c=((x2-x3)**2+(y2-y3)**2)**0.5
s=(a+b+c)/2
ss=(s*(s-a)*(s-b)*(s-c))**0.5
sina=2*ss/b/c
r=a/sina/2
a*=a
b*=b
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>
|
s095321992 | p00010 | Accepted | import math
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
a2 = y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2
px = ((y1 - y3) * a1 - (y1 - y2) * a2) / \
(2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3))
py = ((x1 - x3) * a1 - (x1 - x2) * a2) / \
(2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3))
r = math.hypot(x1 - px, y1 - py)
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>
|
s373464496 | p00010 | Accepted | N = int(input()) #num of test case
for i in range(N):
#one test case
x1, y1, x2, y2, x3, y3 = map(float, input().split())
#vertices
a = complex(x1, y1)
b = complex(x2, y2)
c = complex(x3, y3)
#make c = 0 by parallel transformation
a -= c
b -= c
z0 = abs(a)**2 * b - abs(b)**2 * a
z0 /= a.conjugate() * b - a * b.conjugate()
#inverse parallel transformation
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>
|
s725716370 | p00010 | Accepted | #! -*- coding:utf-8 -*-
import math
n = input()
for x in xrange(n):
x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
a1 = 2.0*(x2-x1)
b1 = 2.0*(y2-y1)
x12 = x1**2
y12 = y1**2
c1 = x12-x2**2+y12-y2**2
a2 = 2.0*(x3-x1)
b2 = 2.0*(y3-y1)
c2 = x12-x3**2+y12-y3**2
denom=(a1*b2-a2*b1)
# print "x1^2 : "+str(x12)
# print "y1^2 : "+str(y12)
# print "a1 : "+str(a1)
# print "b1 : "+str(b1)
# print "c1 : "+str(c1)
# print "a2 : "+str(a2)
# print "b2 : "+str(b2)
# print "c2 : "+str(c2)
# print "denom : "+str(denom)
x = (b1*c2-b2*c1)/denom
y = (c1*a2-c2*a1)/denom
r = math.sqrt((x-x1)**2+(y-y1)**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>
|
s506594358 | p00010 | Accepted | for i in range(int(input())):
x1, y1, x2, y2, x3, y3 = list(map(float,input().split()))
a = x2 - x1
b = y2 - y1
c = (x1**2 - x2**2) + (y1**2 - y2**2)
d = x3 - x1
e = y3 - y1
f = (x1**2 - x3**2) + (y1**2 - y3**2)
l = (e*c - b*f) / (a*e - b*d)
m = (c*d - f*a) / (b*d - a*e)
n = -(x1**2 + y1**2 + l*x1 + m*y1)
import math
px = round(-l/2, 3)
py = round(-m/2, 3)
r = round(math.sqrt(l**2 + m**2 - 4*n ) / 2, 3)
print("{:.3f} {:.3f} {:.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>
|
s751255268 | p00010 | Accepted | def circum(x1,y1,x2,y2,x3,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>
|
s938879104 | p00010 | Accepted | import sys
def calc_det(lis):
return lis[0]*lis[3]-lis[1]*lis[2]
def sq(x):
return x*x
for s in sys.stdin:
d = map(float, s.split() )
if len(d) == 1:
continue
x1,y1,x2,y2,x3,y3 = d[0],d[1],d[2],d[3],d[4],d[5]
d11 = 2*(x3-x2)
d12 = 2*(y3-y2)
d21 = 2*(x2-x1)
d22 = 2*(y2-y1)
x11 = sq(x3)-sq(x2)+sq(y3)-sq(y2)
x21 = sq(x2)-sq(x1)+sq(y2)-sq(y1)
y12 = x11
y22 = x21
x0 = calc_det( [x11,d12,x21,d22] )/calc_det( [d11,d12,d21,d22] )
y0 = calc_det( [d11,y12,d21,y22] )/calc_det( [d11,d12,d21,d22] )
r = ( (x0-x1)**2 + (y0-y1)**2 )**0.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>
|
s520573129 | p00010 | Accepted | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
n = int(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>
|
s605000142 | p00010 | Accepted | # -*- coding: utf-8 -*-
import math
class Point_Class():
def __init__(self, x, y):
self.x = x
self.y = y
def calcCenter(p1, p2, p3):
p = ((p1.y-p2.y)*(p3.x*p3.x+p1.y*p2.y)+(p2.y-p3.y)*(p1.x*p1.x+p2.y*p3.y)+(p3.y-p1.y)*(p2.x*p2.x+p3.y*p1.y)) / ((-2)*(p1.y*(p2.x-p3.x)+p2.y*(p3.x-p1.x)+p3.y*(p1.x-p2.x)))
q = ((p1.x-p2.x)*(p3.y*p3.y+p1.x*p2.x)+(p2.x-p3.x)*(p1.y*p1.y+p2.x*p3.x)+(p3.x-p1.x)*(p2.y*p2.y+p3.x*p1.x)) / ((-2)*(p1.x*(p2.y-p3.y)+p2.x*(p3.y-p1.y)+p3.x*(p1.y-p2.y)))
return Point_Class(p, q)
def calcRadius(p, pc):
return math.sqrt(pow((p.x-pc.x), 2)+pow((p.y-pc.y), 2))
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
p1 = Point_Class(x1, y1)
p2 = Point_Class(x2, y2)
p3 = Point_Class(x3, y3)
pc = calcCenter(p1, p2, p3)
r = calcRadius(p1, pc)
print "%.3f %.3f %.3f" %(pc.x, pc.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>
|
s023453487 | p00010 | Accepted | def perpendicular_bisector(p, q):
x = (q[0] - p[0])
y = (q[1] - p[1])
return (2 * x, 2 * y, p[0]**2-q[0]**2+p[1]**2-q[1]**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(float, 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('{0:.3f} {1:.3f} {2:.3f}'.format(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>
|
s595740441 | p00010 | Accepted | from math import sqrt
def circle(x1, y1, x2, y2, x3, y3):
if x1 == 0:
dx = 1
x1 = x1 + dx
x2 = x2 + dx
x3 = x3 + dx
else:
dx = 0
if y2 == 0:
dy = 1
y1 = y1 + dy
y2 = y2 + dy
y3 = y3 + dy
else:
dy = 0
A = [[x1, y1, 1, 1, 0, 0],[x2, y2, 1, 0, 1, 0],[x3, y3, 1, 0, 0, 1]]
# print(A)
for i in range(3):
A[0] = [x/A[0][0] for x in A[0]]
A[1] = [A[1][j] - A[1][0] * A[0][j] for j in range(6)]
A[2] = [A[2][j] - A[2][0] * A[0][j] for j in range(6)]
# print(A)
for j in range(3):
A[j] = A[j][1:] + A[j][:1]
A = A[1:] + A[:1]
# print(A)
for i in range(3):
A[i] = A[i][:3]
# print(A)
V = [-x1**2-y1**2, -x2**2-y2**2, -x3**2-y3**2]
M = [(A[i][0] * V[0] + A[i][1] * V[1] + A[i][2] * V[2]) for i in range(3)]
xcenter = -0.5 * M[0] - dx
ycenter = -0.5 * M[1] - dy
radius = sqrt((M[0]**2) /4 + (M[1]**2) /4 - M[2])
return xcenter, ycenter, radius
n = int(input())
for line in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
xc, yc, ra = circle(x1, y1, x2, y2, x3, y3)
print('%.3f %.3f %.3f' % (xc, yc, ra)) | 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>
|
s273583003 | p00010 | Accepted | import math
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, 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>
|
s974707088 | p00010 | Accepted | import math
def solve(a,b,c,d,e,f):
x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
r = math.hypot(x-a, y-b)
return x,y,r
n = int(input())
for _ in range(n):
a,b,c,d,e,f = map(float, input().split())
x,y,r = solve(a,b,c,d,e,f)
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>
|
s701215159 | p00010 | Accepted | import math
n = int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
a1,b1,c1 = 2*(x2-x1),2*(y2-y1), (x1**2 - x2 **2 + y1 ** 2 - y2 ** 2)
a2,b2,c2 = 2*(x3-x1), 2*(y3-y1), (x1**2 - x3 **2 + y1 ** 2 - y3 ** 2)
p1 = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
p2 = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
r = math.hypot(x1-p1, y1-p2)
temp = [p1,p2,r]
ans = map(lambda x:round(x,3),temp)
print("%03.3f %03.3f %03.3f"%(temp[0],temp[1],temp[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>
|
s034249254 | p00010 | Accepted | import math
def Cramer(c):
den = c[0]*c[4] - c[1]*c[3]
return [(c[2]*c[4] - c[1]*c[5]) / den, (c[0]*c[5] - c[2]*c[3]) / den]
n = eval(input())
for i in range(n):
c = [eval(item) for item in input().split()]
sol = Cramer([2*(c[0] - c[2]),\
2*(c[1] - c[3]),\
c[0]**2 + c[1]**2 - c[2]**2 - c[3]**2,\
2*(c[0] - c[4]),\
2*(c[1] - c[5]),\
c[0]**2 + c[1]**2 - c[4]**2 - c[5]**2])
r = math.sqrt((sol[0] - c[0])**2+(sol[1] - c[1])**2)
print('%.3f %.3f %.3f' %(sol[0], sol[1], 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>
|
s794785392 | p00010 | Accepted | for _ in range(int(input())):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
d = 2 * (x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3 + x1 * y2 - x2 * y1)
px = ((y2 - y3) * (x1 ** 2 + y1 ** 2) + (y3 - y1) * (x2 ** 2 + y2 ** 2) + (y1 - y2) * (x3 ** 2 + y3 ** 2)) / d
py = -1 * ((x2 - x3) * (x1 ** 2 + y1 ** 2) + (x3 - x1) * (x2 ** 2 + y2 ** 2) + (x1 - x2) * (x3 ** 2 + y3 ** 2)) / d
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, ((x1 - px) ** 2 + (y1 - py) ** 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>
|
s333881423 | p00010 | Accepted | for _ in[0]*int(input()):
a,d,b,e,c,f=map(float,input().split())
z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5)) | 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>
|
s466402039 | p00010 | Accepted | import math
def simultaneous_equasion(a, b, c, d, e, f):
"??£???????¨????"
det = a * d - b * c
a11 = d / det
a12 = - b / det
a21 = - c / det
a22 = a / det
return a11 * e + a12 * f, a21 * e + a22 * f
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
# ?????????O??¨????????¨???OP1 ^ 2 = OP2 ^ 2
# (x - x1) ^ 2 + (y - y1) ^ 2 = (x - x2) ^ 2 + (y - y2) ^ 2
# - 2 * x * x1 + x1 ^ 2 - 2 * y * y1 + y1 ^ 2 = - 2 * x * x2 + x2 ^ 2 - 2 * y * y2 + y2 ^ 2
# 2 * (x1 - x2) * x + 2 * (y1 - y2) * y = x1 ^ 2 + y2 ^ 2 - x2 ^ 2 - y2 ^ 2
a = 2 * (x1 - x2)
b = 2 * (y1 - y2)
c = 2 * (x1 - x3)
d = 2 * (y1 - y3)
e = x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2
f = x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2
px, py = simultaneous_equasion(a, b, c, d, e, f)
r = math.sqrt((px - x1) ** 2 + (py - y1) ** 2)
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>
|
s667130325 | p00010 | Accepted | # -*- coding: utf-8 -*-
import sys
def length(a, b):
return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5
def solve_sim_equ(a, b, c, d, e, f):
'''
From Problem 0004.
This function solves following equation.
ax + by = c
dx + ey = f
'''
if a==0 and d==0:
if b==0 and e==0:
return 0., 0.
if b != 0:
return 0., c/b+0.
else:
return 0., f/e+0.
elif b==0 and e==0:
if a != 0:
return 0., d/a+0.
else:
return 0., a/d+0.
if b == 0:
a, d = d, a
b, e = e, b
c, f = f, c
g = e / b
x = (g*c - f) / (g*a - d)
y = (c - a*x) / b
return x+0., y+0.
def circumscribed_circle(x, y, z):
def get_equ_coef(p, q):
h_x = (p[0] + q[0]) / 2
h_y = (p[1] + q[1]) / 2
a = q[1] - p[1]
b = p[0] - q[0]
c = b * h_x - a * h_y
return b, -a, c
coef = get_equ_coef(x, y) + get_equ_coef(y, z)
center = solve_sim_equ(*coef)
r = length(center, x)
return center, r
def main():
N = int(input())
for i in range(N):
vs = [float(v) for v in input().split()]
a = (vs[0], vs[1])
b = (vs[2], vs[3])
c = (vs[4], vs[5])
center, r = circumscribed_circle(a, b, c)
print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))
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>
|
s398805927 | p00010 | Accepted | import math
n=int(input())
for i in range(n):
deta=[float(i) for i in input().split()]
h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
sub=(h1+h2+h3)/2
s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
sum=((h1*h2*h3)/s)/4
a=2*deta[2]-2*deta[0]
b=2*deta[3]-2*deta[1]
c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
d=2*deta[4]-2*deta[2]
e=2*deta[5]-2*deta[3]
f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))
x=(e*c-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum)) | 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>
|
s737007763 | p00010 | Accepted | import math
n = input()
for i in xrange(n):
x1, y1, x2, y2, x3, y3 = map(float, raw_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)-2*(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)-2*(x1-x2)*(y1-y3))
print '%.3f %.3f %.3f'%(round(p,3), round(q,3), round(math.sqrt((x1-p)**2+(y1-q)**2), 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>
|
s933546471 | p00010 | Accepted | from math import sqrt
n = int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = list(map(float, input().split()))
c = 2*((x2 - x1)*(y3 - y1) - (y2 - y1)*(x3 - x1))
ox = ((y3 - y1)*(x2**2 - x1**2 + y2**2 - y1**2) + (y1 - y2)*(x3**2 - x1**2 + y3**2 - y1**2))/c
oy = ((x1 - x3)*(x2**2 - x1**2 + y2**2 - y1**2) + (x2 - x1)*(x3**2 - x1**2 + y3**2 - y1**2))/c
r = sqrt((x1-ox)**2+(y1-oy)**2)
print("{0:.3f} {1:.3f} {2:.3f}".format(ox+0.0, oy+0.0, r+0.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>
|
s187920197 | p00010 | Accepted | import math
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 - f*b)/(a*e - b*d)
y = (c*d - f*a)/(b*d - e*a)
r = math.sqrt((x1 - x)**2 + (y1 - y)**2)
x = round(x,3)
y = round(y,3)
r = round(r,3)
if x == -0.0:
x = 0.0
if y == -0.0:
y = 0.0
print("{0:.3f}".format(x),end = ' ')
print("{0:.3f}".format(y),end = ' ')
print("{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>
|
s135004720 | p00010 | Accepted | from math import cos, sin, sqrt, radians, degrees, acos, fabs
if __name__ == '__main__':
epsilon = 1e-9
# ??????????????\???
num = int(input())
for i in range(num):
x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split(' ')]
# ??????????????§????§???¢???cos???????±???????arccos??§?§???????????????????
a = sqrt((x1-x2)**2 + (y1-y2)**2)
b = sqrt((x2-x3)**2 + (y2-y3)**2)
c = sqrt((x1-x3)**2 + (y1-y3)**2)
cosA = (b**2+c**2-a**2)/(2*b*c)
# ???????§???????????????°?????£????????????????????\????????????????±????????????¨?????§?????????
r = a / sin(acos(cosA)) / 2
"""
??????O?????§?¨????(x, y)??¨????????¨
(x-x1)**2 + (y-y1)**2 = (x-x2)**2 + (y-y2)**2
x**2 -2*x1*x + x1**2 + y**2 -2*y1*y + y1**2 = ... -2*x2*x, x2**2, -2*y2*y, y2**2
?????¨????????¨ (-2*x1 + 2*x2)x + (-2y1 + 2*y2)y + (x1**2 + y1**2 - x2**2 - y2**2) = 0
x1, x3???????????????????§????
(-2*x1 + 2*x3)x + (-2y1 + 2*y3)y + (x1**2 + y1**2 - x3**2 - y3**2) = 0
"""
A = -2*x1 + 2*x2
B = -2*y1 + 2*y2
C = -2*x1 + 2*x3
D = -2*y1 + 2*y3
E = x1**2 + y1**2 - x2**2 - y2**2
F = x1**2 + y1**2 - x3**2 - y3**2
x = 1/(A*D-B*C) * (D*E - B*F)
y = 1/(A*D-B*C) * (-C*E + A*F)
# ?¨????????????¨?????? -0.0 ???????????´???????????¶?????? 0.0 ?????????
if fabs(x) < epsilon:
x = 0.0
if fabs(y) < epsilon:
y = 0.0
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>
|
s464705283 | p00010 | Accepted | from math import sqrt, fabs
def calcu_cirucumcenter(x1, y1, x2, y2, x3, y3):
"""
??????O?????§?¨????(x, y)??¨????????¨
(x-x1)**2 + (y-y1)**2 = (x-x2)**2 + (y-y2)**2
x**2 -2*x1*x + x1**2 + y**2 -2*y1*y + y1**2 = ... -2*x2*x, x2**2, -2*y2*y, y2**2
?????¨????????¨ (-2*x1 + 2*x2)x + (-2y1 + 2*y2)y + (x1**2 + y1**2 - x2**2 - y2**2) = 0
x1, x3???????????????????§????
(-2*x1 + 2*x3)x + (-2y1 + 2*y3)y + (x1**2 + y1**2 - x3**2 - y3**2) = 0
??????????????¢????????\????????¢???????????£???????¨??????¨???????§£???
| a b | = |e|
| c d | |f|
"""
a = -2 * x1 + 2 * x2
b = -2 * y1 + 2 * y2
c = -2 * x1 + 2 * x3
d = -2 * y1 + 2 * y3
e = -1* (x1 ** 2 + y1 ** 2 - x2 ** 2 - y2 ** 2)
f = -1 * (x1 ** 2 + y1 ** 2 - x3 ** 2 - y3 ** 2)
x = 1 / (a * d - b * c) * (d * e - b * f)
y = 1 / (a * d - b * c) * (-c * e + a * f)
return x, y
if __name__ == '__main__':
epsilon = 1e-9
# ??????????????\???
num = int(input())
for i in range(num):
x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split(' ')]
# ?????\????????????(??????)????±???????
x, y = calcu_cirucumcenter(x1, y1, x2, y2, x3, y3)
# ?¨????????????¨?????? -0.0 ???????????´???????????¶?????? 0.0 ?????????
if fabs(x) < epsilon:
x = 0.0
if fabs(y) < epsilon:
y = 0.0
# ????????????????????§????????¢?????????
r = 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>
|
s878433463 | p00010 | Accepted | n = int(input())
datasets = [0]*n
#datasets[k] == [x1k,y1k,x2k,y2k,x3k,y3k]
for i in range(0,n):
datasets[i] = list(map(float,input().split()))
for data in datasets:
x1p2=(data[0]+data[2])
x1m2=(data[0]-data[2])
x1p3=(data[0]+data[4])
x1m3=(data[0]-data[4])
y1p2=(data[1]+data[3])
y1m2=(data[1]-data[3])
y1p3=(data[1]+data[5])
y1m3=(data[1]-data[5])
x=(x1p2*x1m2*y1m3+y1p2*y1m2*y1m3-x1p3*x1m3*y1m2-y1p3*y1m3*y1m2)/(2*(x1m2*y1m3-x1m3*y1m2))
y=(y1p2*y1m2*x1m3+x1p2*x1m2*x1m3-y1p3*y1m3*x1m2-x1p3*x1m3*x1m2)/(2*(y1m2*x1m3-y1m3*x1m2))
r=((x-data[0])**2+(y-data[1])**2)**(1/2)
if x == 0.000:
x=0
if y == 0.000:
y=0
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>
|
s671909772 | p00010 | Accepted | class vertex(object):
def __init__(self,a):
self.x=a[0]
self.y=a[1]
class circle(object):
def __init__(self,p,r):
self.px=p.x
self.py=p.y
self.r=r
class triangle(object):
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
import math
self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2)
self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2)
self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2)
c=self.ab
a=self.bc
b=self.ca
self.cosA=(b**2+c**2-a**2)/(2*b*c)
self.cosB=(a**2+c**2-b**2)/(2*a*c)
self.cosC=(b**2+a**2-c**2)/(2*b*a)
self.sinA=math.sqrt(1-self.cosA**2)
self.sinB=math.sqrt(1-self.cosB**2)
self.sinC=math.sqrt(1-self.cosC**2)
self.sin2A=2*self.sinA*self.cosA
self.sin2B=2*self.sinB*self.cosB
self.sin2C=2*self.sinC*self.cosC
def area(self):
import math
s=(self.ab+self.bc+self.ca)/2
S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca))
return S
def circumscribed(self):
R=self.ab/(2*self.sinC)
px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C)
py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C)
px=round(px,3)
py=round(py,3)
R=round(R,3)
p=vertex((px,py))
return circle(p,R)
n=eval(input())
p1=[]
p2=[]
p3=[]
for i in range(n):
a,b,c,d,e,f=list(map(float,input().split()))
p1.append(vertex((a,b)))
p2.append(vertex((c,d)))
p3.append(vertex((e,f)))
for i in range(n):
Triangle=triangle(p1[i],p2[i],p3[i])
Circle=Triangle.circumscribed()
print('%.3f %.3f %.3f'%(Circle.px,Circle.py,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>
|
s272144446 | 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>
|
s722817816 | p00010 | Accepted | # -*- coding:utf-8 -*-
import sys
import math
def solve(x1,y1,x2,y2,x3,y3):
z1 = -1 * (x1**2 + y1**2)
z2 = -1 * (x2**2 + y2**2)
z3 = -1 * (x3**2 + y3**2)
a11,a12,a13 = x1,y1,1
a21,a22,a23 = x2,y2,1
a31,a32,a33 = x3,y3,1
det = a11*a22*a33 + a21*a32*a13 + a31*a12*a23 - a11*a32*a23 - a31*a22*a13 - a21*a12*a33
l = ((a22*a33 - a23*a32)*z1 + (a13*a32 - a12*a33)*z2 + (a12*a23 - a13*a22)*z3)/det
m = ((a23*a31 - a21*a33)*z1 + (a11*a33 - a13*a31)*z2 + (a13*a21 - a11*a23)*z3)/det
n = ((a21*a32 - a22*a31)*z1 + (a12*a31 - a11*a32)*z2 + (a11*a22 - a12*a21)*z3)/det
x,y,r = round(-l/2,3),round(-m/2,3),round(math.sqrt((l**2)/4+(m**2)/4-n),3)
sol = [x, y, r]
return sol
n,count = int(input()),0
array = []
for i in sys.stdin:
array.append(i)
count += 1
if count == n:
break
for i in range(len(array)):
x = array[i]
p = x.split()
res = solve(float(p[0]),float(p[1]),float(p[2]),float(p[3]),float(p[4]),float(p[5]))
print('{:.3f} {:.3f} {:.3f}'.format(res[0], res[1], res[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>
|
s948664191 | p00010 | Accepted | import sys
import math
def to_f(e):
return float(e)
n = int(raw_input().rstrip())
for i in range(n):
line = raw_input().rstrip()
x1, y1, x2, y2, x3, y3 = map(to_f, line.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
xp = (b1*c2-b2*c1)/(a1*b2-a2*b1)
yp = (c1*a2-c2*a1)/(a1*b2-a2*b1)
r = round(math.sqrt((xp-x1)**2+(yp-y1)**2), 3)
#print(str(xp.format()+ " " + str(yp) + " " + str(r))
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>
|
s792206888 | p00010 | Accepted | for i in range(int(input())):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
c = (x1-x2)**2 + (y1-y2)**2
a = (x2-x3)**2 + (y2-y3)**2
b = (x3-x1)**2 + (y3-y1)**2
# 16s^2
s = 2*(a*b + b*c + c*a) - (a*a + b*b + c*c)
px = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3) / s
py = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3) / s
ar = a**0.5
br = b**0.5
cr = c**0.5
r = ar*br*cr / ((ar+br+cr)*(-ar+br+cr)*(ar-br+cr)*(ar+br-cr))**0.5
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>
|
s263333739 | p00010 | Accepted | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
n = int(sys.stdin.readline())
for i in range(n):
x1,y1,x2,y2,x3,y3 = list(map(float, sys.stdin.readline().split()))
a = ((x3-x2)**2 + (y3-y2)**2)**0.5
b = ((x1-x3)**2 + (y1-y3)**2)**0.5
c = ((x2-x1)**2 + (y2-y1)**2)**0.5
r = a*b*c / ((a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c))**0.5
a2,b2,c2 = a**2,b**2,c**2
x = (a2*(b2+c2-a2)*x1 + b2*(c2+a2-b2)*x2 + c2*(a2+b2-c2)*x3) / \
(a2*(b2+c2-a2) + b2*(c2+a2-b2) + c2*(a2+b2-c2))
y = (a2*(b2+c2-a2)*y1 + b2*(c2+a2-b2)*y2 + c2*(a2+b2-c2)*y3) / \
(a2*(b2+c2-a2) + b2*(c2+a2-b2) + c2*(a2+b2-c2))
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>
|
s666559415 | 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>
|
s995075927 | p00010 | Accepted | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
try:
x = (z1 - cy1 * y) / cx1
except ZeroDivisionError:
x = (z2 - cy2 * y) / cx2
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (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>
|
s154764030 | p00010 | Accepted | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1 if cx1 else (z2 - cy2 * y) / cx2
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
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>
|
s262056243 | p00010 | Accepted | def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
dcy, dz = cx2 * cy1 - cx1 * cy2, cx2 * z1 - cx1 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1 if cx1 else (z2 - cy2 * y) / cx2
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
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>
|
s366237897 | p00010 | Accepted | n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
a = pow(pow(x3-x2, 2) + pow(y3-y2, 2), 0.5)
b = pow(pow(x1-x3, 2) + pow(y1-y3, 2), 0.5)
c = pow(pow(x2-x1, 2) + pow(y2-y1, 2), 0.5)
cosA = (b**2+c**2-a**2) / (2*b*c)
sinA = 1-cosA**2
r = a / pow(sinA, 0.5) / 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)
print("{0:.3f} {1:.3f} {2:.3f}".format(-l/2, -m/2, 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>
|
s664393921 | p00010 | Accepted | # -*- coding: utf-8 -*-
import sys
import os
import math
N = int(input())
for i in range(N):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
c = 2 * ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1))
x = ((y3 - y1) * (x2 ** 2 - x1 ** 2 + y2 ** 2 - y1 ** 2) + (y1 - y2) * (x3 ** 2 - x1 ** 2 + y3 ** 2 - y1 ** 2)) / c
y = ((x1 - x3) * (x2 ** 2 - x1 ** 2 + y2 ** 2 - y1 ** 2) + (x2 - x1) * (x3 ** 2 - x1 ** 2 + y3 ** 2 - y1 ** 2)) / c
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>
|
s374212381 | p00010 | Accepted | import math
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split()) # Get variables
a = 2 * (x2 - x1)
b = 2 * (y2 - y1)
c = math.pow(x2, 2) + math.pow(y2, 2) - math.pow(x1, 2) - math.pow(y1, 2)
d = 2 * (x3 - x1)
e = 2 * (y3 - y1)
f = math.pow(x3, 2) + math.pow(y3, 2) - math.pow(x1, 2) - math.pow(y1, 2)
px = (c * e - b * f) / (a * e - b * d)
py = (a * f - c * d) / (a * e - b * d)
r = math.sqrt(math.pow(x1 - px, 2) + math.pow(y1 - py, 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>
|
s052458025 | p00010 | Accepted | from math import sqrt
n = int(input())
for i in range(n):
l = input()
x1,y1,x2,y2,x3,y3=map(float,l.split(' '))
a_2 = (x1 - x2)**2 + (y1 - y2)**2
b_2 = (x2 - x3)**2 + (y2 - y3)**2
c_2 = (x3 - x1)**2 + (y3 - y1)**2
cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)
sin_a_2 = 1 - cos_a_2
r = round(sqrt(a_2/sin_a_2)/2,3)
a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)
b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)
c = (y2 - y1)*(x3 - x1)
d = (y3 - y1)*(x2 - x1)
py = round((a-b)/(c-d)/2,3)
a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)
b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)
c = (x2 - x1)*(y3 - y1)
d = (x3 - x1)*(y2 - y1)
px = round((a-b)/(c-d)/2,3)
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>
|
s903524426 | p00010 | Accepted | from math import sqrt
n = int(input())
for i in range(n):
l = input()
x1,y1,x2,y2,x3,y3=map(float,l.split(' '))
a_2 = (x1 - x2)**2 + (y1 - y2)**2
b_2 = (x2 - x3)**2 + (y2 - y3)**2
c_2 = (x3 - x1)**2 + (y3 - y1)**2
cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)
sin_a_2 = 1 - cos_a_2
r = round(sqrt(a_2/sin_a_2)/2,3)
a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)
b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)
c = (y2 - y1)*(x3 - x1)
d = (y3 - y1)*(x2 - x1)
py = round((a-b)/(c-d)/2,3) + 0
a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)
b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)
c = (x2 - x1)*(y3 - y1)
d = (x3 - x1)*(y2 - y1)
px = round((a-b)/(c-d)/2,3) + 0
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>
|
s608076616 | p00010 | Accepted | import math
n = int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float,input().split())
a1,b1,c1 = 2*(x2-x1),2*(y2-y1), (x1**2 - x2 **2 + y1 ** 2 - y2 ** 2)
a2,b2,c2 = 2*(x3-x1), 2*(y3-y1), (x1**2 - x3 **2 + y1 ** 2 - y3 ** 2)
p1 = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
p2 = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
r = math.hypot(x1-p1, y1-p2)
temp = [p1,p2,r]
ans = map(lambda x:round(x,3),temp)
print("%03.3f %03.3f %03.3f"%(temp[0],temp[1],temp[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>
|
s778033033 | p00010 | Accepted | # coding: utf-8
# Here your code !
import math
num = int(input())
for i in range(num):
x1,y1,x2,y2,x3,y3 = map(float,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)
p1 = (b1*c2 - b2*c1) / (a1*b2 - a2*b1)
p2 = (c1*a2 - c2*a1) / (a1*b2 - a2*b1)
r = math.hypot(x1-p1, y1-p2)
temp = [p1,p2,r]
ans = map(lambda x:round(x,3),temp)
print("%03.3f %03.3f %03.3f"%(temp[0],temp[1],temp[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>
|
s129007203 | p00010 | Accepted | import sys
import math
n = int(sys.stdin.readline().rstrip())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(float, sys.stdin.readline().rstrip().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)-2*(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)-2*(x1-x2)*(y1-y3))
r = math.sqrt((p-x1)**2 + (q-y1)**2)
print("{:0.3f} {:0.3f} {:0.3f}".format(round(p,3),round(q,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>
|
s167038521 | p00010 | Accepted | p = int(input())
for i in range(p):
x1, y1, x2, y2, x3, y3 = map(float, input().split(" "))
xa, ya, xb, yb = x2-x1, y2-y1, x3-x1, y3-y1
a = complex(xa, ya)
b = complex(xb, yb)
z0 = abs(a) ** 2 * b - abs(b) **2 * a
z0 /= a.conjugate() * b - a * b.conjugate()
z = z0 + complex(x1, y1)
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>
|
s768014470 | p00010 | Accepted | from math import acos
from math import sin
def ang(ax, ay, ox, oy, bx, by):
oax, oay = ax - ox, ay - oy
obx, oby = bx - ox, by - oy
r1, r2 = oax ** 2 + oay ** 2, obx ** 2 + oby ** 2
return acos((oax * obx + oay * oby) / (r1 * r2) ** 0.5)
def circumcircle(x1, y1, x2, y2, x3, y3):
s2A = sin(2 * ang(x3, y3, x1, y1, x2, y2))
s2B = sin(2 * ang(x1, y1, x2, y2, x3, y3))
s2C = sin(2 * ang(x2, y2, x3, y3, x1, y1))
px = (s2A * x1 + s2B * x2 + s2C * x3) / (s2A + s2B + s2C) + 0.
py = (s2A * y1 + s2B * y2 + s2C * y3) / (s2A + s2B + s2C) + 0.
r = (((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5) / (2 * sin(ang(x2, y2, x1, y1, x3, y3))) + 0.
return px, py, r
n = int(input())
for i in range(n):
print("{0[0]:.3f} {0[1]:.3f} {0[2]:.3f}".format(
circumcircle(*tuple(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>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.