s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s002692553
p00008
u392970366
1596670285
Python
Python3
py
Accepted
50
5596
254
while True: try: n = int(input()) except: break ans = 0 for a in range(10): for b in range(10): for c in range(10): d = n - (a + b + c) ans += 0 <= d <= 9 print(ans)
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,102
s436919250
p00008
u309196579
1596606764
Python
Python3
py
Accepted
50
5592
254
while True: try: n = int(input()) except: break ans = 0 for a in range(10): for b in range(10): for c in range(10): d = n - (a + b + c) ans += 0 <= d <= 9 print(ans)
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,103
s462512391
p00008
u187074069
1595929176
Python
Python3
py
Accepted
20
5592
320
while True: try: n = int(input()) if n > 18: n = 36 - n ans = (n+1)*(n+2)*(n+3)/6 if n >= 10: n = n - 10 ans = ans - 2*(n+1)*(n+2)*(n+3)/3 if n < 0: ans = 0 print(int(ans)) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,104
s591757975
p00008
u260980560
1588728631
Python
Python3
py
Accepted
40
5592
343
for line in open(0).readlines(): N = int(line) lim = min(9, N) ans = 0 if 0 <= N <= 36: for a in range(0, lim+1): for b in range(0, lim+1): for c in range(0, lim+1): d = N - a - b - c if 0 <= d <= lim: ans += 1 print(ans)
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,105
s798823325
p00008
u230927103
1586444927
Python
Python3
py
Accepted
50
5596
333
while True: try: count = 0 n = int(input()) for a in range(10): for b in range(10): for c in range(10): d = n - a - b - c if (d >= 0 and d <= 9): count += 1 print(count) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,106
s570402281
p00008
u933957884
1572692191
Python
Python3
py
Accepted
80
5612
186
import sys; print("\n".join(str(sum(1 for n in [int(in_n)] for a in range(10) for b in range(a, a+10) for c in range(b, b+10) for d in range(c, c+10) if d == n)) for in_n in sys.stdin))
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,107
s895452239
p00008
u586792237
1564929728
Python
Python3
py
Accepted
30
5596
239
a = [0 for i in range(51)] for i in range(10): for j in range(10): for k in range(10): for l in range(10): a[i + j + k + l] += 1 while True: try: n = int(input()) print(a[n]) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,108
s507590470
p00008
u821561321
1564923201
Python
Python3
py
Accepted
30
5600
193
e=[0]*51 for a in range(10): for b in range(10): for c in range(10): for d in range(10): e[sum([a,b,c,d])]+=1 while 1: try: print(e[int(input())]) except: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,109
s972251868
p00008
u607723579
1564814490
Python
Python3
py
Accepted
30
5604
306
ans = [0 for i in range(51)] for i in range(10): for j in range(10): for k in range(10): for l in range(10): ans[i+j+k+l] += 1 #for i in range(50+1): # print(i, ans[i]) while True: try: print(ans[int(input())]) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,110
s412345148
p00008
u614095715
1560533257
Python
Python3
py
Accepted
30
5644
193
import itertools import sys com = [0] * 51 r10 = range(10) for a,b,c,d in itertools.product(r10,r10,r10,r10): com[a+b+c+d] += 1 for line in sys.stdin.readlines(): print(com[int(line)])
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,111
s089923946
p00008
u506537276
1560143603
Python
Python3
py
Accepted
30
5596
244
a = [0 for i in range(51)] for i in range(10): for j in range(10): for k in range(10): for l in range(10): a[i + j + k + l] += 1 while True: try: n = int(input()) print(a[n]) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,112
s409324128
p00008
u406093358
1555463373
Python
Python
py
Accepted
100
4648
286
import sys for line in sys.stdin: n = int(line) cnt = 0 for i in range(0, 10): for j in range(0, 10): for k in range(0, 10): for p in range(0, 10): if i+j+k+p == n: cnt += 1 break if i+j+k == n: break if i+j == n: break if i == n: break print cnt
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,113
s748709492
p00008
u195186080
1550733079
Python
Python3
py
Accepted
50
5600
421
def calc(n, x): # n個の数(0~9)の和でxが作れるかどうかを判別する if n == 1: if x <= 9: return 1 else: return 0 else: num = 0 for i in range(10): if x-i < 0: continue num += calc(n-1, x-i) return num while True: try: print(calc(4, int(input()))) except: exit(0)
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,114
s716785144
p00008
u350155409
1547293441
Python
Python3
py
Accepted
20
5600
204
import sys n = [0]*51 for i in range(10): for j in range(10): for k in range(10): for l in range(10): n[i+j+k+l] += 1 for i in sys.stdin: print(n[int(i)])
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,115
s024283853
p00008
u080014366
1547036763
Python
Python3
py
Accepted
90
5596
318
def count(a):#関数「count」を定義 count = 0 if a<=36: for i in range(10):#()内は0から一つ前までの数 for j in range(10): for k in range(10): for l in range(10): if i+j+k+l==a: count +=1 print(count) while True: try: a=int(input()) count(a) except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,116
s068219139
p00008
u717526540
1541637392
Python
Python3
py
Accepted
50
5588
278
while(1): try: n = int(input()) except: break cnt = 0 for a in range(10): for b in range(10): for c in range(10): d = n - a - b - c if 0 <= d < 10: cnt += 1 print(cnt)
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,117
s738138248
p00008
u853158149
1521965057
Python
Python3
py
Accepted
30
5604
244
num = [0 for i in range(51)] for a in range(10): for b in range(10): for c in range(10): for d in range(10): num[a+b+c+d] += 1 while 1: try: print(num[int(input())]) except: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,118
s273576601
p00008
u197615660
1374476960
Python
Python
py
Accepted
20
4212
212
while True: try: n = int(raw_input()) judge = 0 for i in range(10): for j in range(10): for k in range(10): if -1 < n - i - j - k < 10: judge += 1 print judge except EOFError: break
p00008
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = 35, we have 4 different combinations of (<var>a, b, c, d</var>): (<var>8, 9, 9, 9</var>), (<var>9, 8, 9, 9</var>), (<var>9, 9, 8, 9</var>), and (<var>9, 9, 9, 8</var>). </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of <var>n</var> (1 &le; <var>n</var> &le; 50) in a line. The number of datasets is less than or equal to 50. </p> <H2>Output</H2> <p> Print the number of combination in a line. </p> <H2>Sample Input</H2> <pre> 35 1 </pre> <H2>Output for the Sample Input</H2> <pre> 4 4 </pre>
35 1
4 4
5,119
s862542423
p00009
u957021183
1504684684
Python
Python3
py
Accepted
80
14372
757
# Aizu Problem 0009: Prime Number # import sys, math, os, bisect # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def primes2(n): """ Input n>=6, Returns a list of primes, 2 <= p < n """ n, correction = n-n%6+6, 2-(n%6>1) sieve = [True] * (n//3) for i in range(1,int(n**0.5)//3+1): if sieve[i]: k=3*i+1|1 sieve[ k*k//3 ::2*k] = [False] * ((n//6-k*k//6-1)//k+1) sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1) return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]] primes = primes2(10**6) for line in sys.stdin: n = int(line) idx = bisect.bisect_right(primes, n) print(idx)
p00009
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. </p> <H2>Input</H2> <p> Input consists of several datasets. Each dataset has an integer <var>n</var> (1 &le; <var>n</var> &le; 999,999) in a line. </p> <p> The number of datasets is less than or equal to 30. </p> <H2>Output</H2> <p> For each dataset, prints the number of prime numbers. </p> <H2>Sample Input</H2> <pre> 10 3 11 </pre> <H2>Output for the Sample Input</H2> <pre> 4 2 5 </pre>
10 3 11
4 2 5
5,120
s707025188
p00010
u995990363
1530848494
Python
Python3
py
Accepted
20
5696
1,196
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()
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,121
s888023198
p00010
u244742296
1409825937
Python
Python3
py
Accepted
30
6984
1,688
# -*- 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()))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,122
s693920046
p00010
u579833671
1410771915
Python
Python
py
Accepted
20
4428
556
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,123
s031239253
p00010
u506132575
1416114717
Python
Python
py
Accepted
20
4376
777
#!/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 '''
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,124
s889427989
p00010
u567380442
1424262005
Python
Python3
py
Accepted
30
6776
743
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,125
s351931260
p00010
u540744789
1426158084
Python
Python
py
Accepted
10
4496
731
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,126
s580932409
p00010
u879226672
1431621030
Python
Python
py
Accepted
20
4412
457
# 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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,127
s989196126
p00010
u067299340
1432816763
Python
Python
py
Accepted
20
4376
471
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,128
s090858081
p00010
u067299340
1432817040
Python
Python
py
Accepted
10
4336
354
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,129
s386023601
p00010
u067299340
1432817248
Python
Python
py
Accepted
20
4336
317
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,130
s122823497
p00010
u067299340
1432817322
Python
Python
py
Accepted
10
4332
312
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,131
s543355455
p00010
u067299340
1432817587
Python
Python
py
Accepted
10
4332
302
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,132
s152540471
p00010
u379956761
1434726722
Python
Python3
py
Accepted
30
6824
531
#!/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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,133
s773101625
p00010
u722431421
1439559123
Python
Python
py
Accepted
10
4360
685
# 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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,134
s040160979
p00010
u722431421
1439560398
Python
Python
py
Accepted
10
4360
685
# 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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,135
s182973471
p00010
u140201022
1443010856
Python
Python
py
Accepted
10
6568
457
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,136
s416647942
p00010
u802625365
1447077872
Python
Python
py
Accepted
10
6480
731
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,137
s095321992
p00010
u777299405
1447135791
Python
Python3
py
Accepted
20
7680
513
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,138
s373464496
p00010
u529386725
1453716676
Python
Python3
py
Accepted
30
7568
553
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,139
s725716370
p00010
u512342660
1455035612
Python
Python
py
Accepted
10
6436
715
#! -*- 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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,140
s991435630
p00010
u867824281
1456973282
Python
Python
py
Accepted
10
6488
731
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,141
s506594358
p00010
u766477342
1457531280
Python
Python3
py
Accepted
30
7668
518
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,142
s751255268
p00010
u650459696
1458379386
Python
Python3
py
Accepted
30
7732
580
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]))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,143
s938879104
p00010
u148101999
1459229246
Python
Python
py
Accepted
20
6504
612
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,144
s520573129
p00010
u915343634
1459349618
Python
Python3
py
Accepted
30
7672
534
#!/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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,145
s605000142
p00010
u130979865
1459902454
Python
Python
py
Accepted
10
6524
908
# -*- 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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,146
s023453487
p00010
u966364923
1460037425
Python
Python3
py
Accepted
30
7940
1,684
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)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,147
s595740441
p00010
u572790226
1460122876
Python
Python3
py
Accepted
30
7820
1,232
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,148
s273583003
p00010
u146816547
1469285358
Python
Python
py
Accepted
10
6536
490
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,149
s974707088
p00010
u896025703
1469537864
Python
Python3
py
Accepted
20
7768
512
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,150
s701215159
p00010
u648595404
1469702541
Python
Python3
py
Accepted
20
7824
483
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]))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,151
s034249254
p00010
u582608581
1470393346
Python
Python3
py
Accepted
30
7660
508
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,152
s794785392
p00010
u358919705
1471820775
Python
Python3
py
Accepted
30
7596
487
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,153
s333881423
p00010
u358919705
1471821390
Python
Python3
py
Accepted
20
7664
289
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,154
s466402039
p00010
u659302741
1477740619
Python
Python3
py
Accepted
30
7776
970
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)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,155
s667130325
p00010
u149199817
1478146853
Python
Python3
py
Accepted
30
7764
1,424
# -*- 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()
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,156
s398805927
p00010
u252368621
1479000288
Python
Python3
py
Accepted
40
7816
693
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,157
s737007763
p00010
u922871577
1479280435
Python
Python
py
Accepted
10
6520
509
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,158
s933546471
p00010
u123687446
1480672642
Python
Python3
py
Accepted
20
7624
470
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,159
s187920197
p00010
u301729341
1481011872
Python
Python3
py
Accepted
30
7756
599
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,160
s135004720
p00010
u811733736
1481252091
Python
Python3
py
Accepted
20
7940
1,598
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,161
s464705283
p00010
u811733736
1481269169
Python
Python3
py
Accepted
30
7784
1,553
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,162
s878433463
p00010
u919202930
1481303850
Python
Python3
py
Accepted
20
7716
694
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,163
s671909772
p00010
u957840591
1482465190
Python
Python3
py
Accepted
30
7704
1,871
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,164
s272144446
p00010
u078042885
1483859447
Python
Python3
py
Accepted
20
7592
313
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)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,165
s722817816
p00010
u711765449
1483867438
Python
Python3
py
Accepted
20
7808
1,065
# -*- 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]))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,166
s948664191
p00010
u252414452
1486039485
Python
Python
py
Accepted
10
6500
534
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,167
s792206888
p00010
u901080241
1488955612
Python
Python3
py
Accepted
30
7708
554
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,168
s263333739
p00010
u459418423
1489557614
Python
Python3
py
Accepted
20
7772
683
#!/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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,169
s666559415
p00010
u011621222
1490023766
Python
Python
py
Accepted
10
6408
334
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,170
s995075927
p00010
u797673668
1490621162
Python
Python3
py
Accepted
60
10188
661
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)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,171
s154764030
p00010
u797673668
1490621316
Python
Python3
py
Accepted
60
10160
601
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,172
s262056243
p00010
u797673668
1490621524
Python
Python3
py
Accepted
20
7760
512
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,173
s366237897
p00010
u546285759
1492401742
Python
Python3
py
Accepted
30
7496
579
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,174
s664393921
p00010
u462831976
1492655576
Python
Python3
py
Accepted
30
7772
553
# -*- 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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,175
s374212381
p00010
u187606290
1493474295
Python
Python3
py
Accepted
20
7720
568
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,176
s052458025
p00010
u519227872
1494010374
Python
Python3
py
Accepted
20
7632
764
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,177
s903524426
p00010
u519227872
1494011136
Python
Python3
py
Accepted
30
7672
772
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))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,178
s608076616
p00010
u618637847
1494896173
Python
Python3
py
Accepted
20
7708
485
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]))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,179
s778033033
p00010
u618637847
1494896351
Python
Python3
py
Accepted
20
7624
539
# 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]))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,180
s129007203
p00010
u922489088
1496133651
Python
Python3
py
Accepted
20
7608
512
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)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,181
s167038521
p00010
u905313459
1496315524
Python
Python3
py
Accepted
20
7500
434
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,182
s768014470
p00010
u354053070
1501910798
Python
Python3
py
Accepted
30
8004
842
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())))))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,183
s434711363
p00010
u957021183
1504763177
Python
Python3
py
Accepted
20
7844
996
# Aizu Problem 0010: Circumscribed Circle of a Triangle # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def circumscribed_circle(x1, y1, x2, y2, x3, y3): d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2) b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2) c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2) s = (a + b + c) / 2 A = math.sqrt(s * (s - a) * (s - b) * (s - c)) r = a * b * c / (4 * A) return px, py, r N = int(input()) for k in range(N): x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()] px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3) print("%.3f %.3f %.3f" % (px, py, r))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,184
s051562628
p00010
u299798926
1505355567
Python
Python3
py
Accepted
30
7772
433
import math a=int(input()) for i in range(a): x1,y1,x2,y2,x3,y3=[float(j) for j in input().split()] A=x1**2+y1**2-x2**2-y2**2 B=x2**2+y2**2-x3**2-y3**2 x12=x1-x2 x23=x2-x3 y12=y1-y2 y23=y2-y3 x=(y23*A-y12*B)/(2*(x12*y23-x23*y12)) if (y12==0): y=(B-2*x23*x)/(2*y23) else: y=(A-2*x12*x)/(2*y12) r=math.sqrt((x1-x)**2+(y1-y)**2) print('{:.3f} {:.3f} {:.3f}'.format(x,y,r))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,185
s075153499
p00010
u395334793
1505644037
Python
Python3
py
Accepted
20
7624
308
for _ in range(int(input())): a,d,b,e,c,f=map(float,input().split()) z=2*(b*f-c*e+c*d-a*f+a*e-b*d) x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,186
s779675306
p00010
u933096856
1505853684
Python
Python3
py
Accepted
40
7724
436
def pp(x): if x==0: x=0 return "{0:.3f}".format(round(x,3)) n=int(input()) for i in range(n): x1,y1,x2,y2,x3,y3=map(float, input().split()) a=2*(x2-x1) b=2*(y2-y1) c=( x2**2 + y2**2 ) - ( x1**2 + y1**2 ) d=2*(x3-x1) e=2*(y3-y1) f=( x3**2 + y3**2 ) - ( x1**2 + y1**2 ) x=(c*e-b*f)/(a*e-b*d) y=(a*f-c*d)/(a*e-b*d) r=( (x-x1)**2 + (y-y1)**2 )**0.5 print(pp(x), pp(y), pp(r))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,187
s751225048
p00010
u072398496
1507685881
Python
Python
py
Accepted
20
6684
522
def line(grad, x, y): return [grad, y - grad * x] def intersection(a, b, c, d): return [-(b-d)/(a-c), -(b-d)/(a-c)*a+b] n = input() for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, raw_input().split()) a, b = line(-1 / ((y1 - y2) / (x1 - x2 + 0.000000001) + 0.000000001), (x1 + x2) / 2, (y1 + y2) / 2) c, d = line(-1 / ((y3 - y2) / (x3 - x2 + 0.000000001) + 0.000000001), (x3 + x2) / 2, (y3 + y2) / 2) px, py = intersection(a, b, c, d) print "%.3f %.3f %.3f" % (px, py, ((px - x1)**2 + (py - y1)**2)**0.5)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,188
s784075347
p00010
u548155360
1512395192
Python
Python3
py
Accepted
20
5716
3,058
# coding=utf-8 import math if __name__ == '__main__': n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) points_list = [[x1, y1], [x2, y2], [x3, y3]] points_list.sort() if points_list[0][0] == points_list[1][0]: py = (points_list[0][1] + points_list[1][1])/2 if points_list[2][1] == points_list[0][1]: px = (points_list[0][0] + points_list[2][0])/2 else: a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0]) a2 = -1/a2_s m13x = (points_list[0][0] + points_list[2][0])/2 m13y = (points_list[0][1] + points_list[2][1])/2 b2 = m13y - a2*m13x px = (py - b2)/a2 elif points_list[1][0] == points_list[2][0]: py = (points_list[1][1] + points_list[2][1])/2 if points_list[2][1] == points_list[0][1]: px = (points_list[0][0]+points_list[2][0])/2 else: a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0]) a2 = -1/a2_s m13x = (points_list[0][0] + points_list[2][0])/2 m13y = (points_list[0][1] + points_list[2][1])/2 b2 = m13y - a2*m13x px = (py - b2)/a2 elif points_list[0][1] == points_list[1][1]: px = (points_list[0][0] + points_list[1][0])/2 a2_s = (points_list[2][1] - points_list[0][1]) / (points_list[2][0] - points_list[0][0]) a2 = -1 / a2_s m13x = (points_list[0][0] + points_list[2][0]) / 2 m13y = (points_list[0][1] + points_list[2][1]) / 2 b2 = m13y - a2 * m13x py = a2*px + b2 elif points_list[0][1] == points_list[2][1]: px = (points_list[0][0] + points_list[2][0])/2 a1_s = (points_list[1][1] - points_list[0][1]) / (points_list[1][0] - points_list[0][0]) a1 = -1 / a1_s m12x = (points_list[0][0] + points_list[1][0]) / 2 m12y = (points_list[0][1] + points_list[1][1]) / 2 b1 = m12y - a1 * m12x py = a1 * px + b1 else: a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0]) a1 = -1/a1_s a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0]) a2 = -1/a2_s m12x = (points_list[0][0] + points_list[1][0]) / 2 m12y = (points_list[0][1] + points_list[1][1]) / 2 m13x = (points_list[0][0] + points_list[2][0]) / 2 m13y = (points_list[0][1] + points_list[2][1]) / 2 b1 = m12y - a1 * m12x b2 = m13y - a2 * m13x px = (b2 - b1)/(a1 - a2) py = a1*px + b1 r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2)) print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,189
s872566194
p00010
u203261375
1513003324
Python
Python3
py
Accepted
30
5664
460
n = int(input()) for _ in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) px = ((y1-y3) * (y1**2-y2**2+x1**2-x2**2) - (y1-y2) * (y1**2-y3**2+x1**2-x3**2)) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3)) py = ((x1-x3) * (x1**2-x2**2+y1**2-y2**2) - (x1-x2) * (x1**2-x3**2+y1**2-y3**2)) / (2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3)) r = ((x1 - px)**2 + (y1 - py)**2)**0.5 print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,190
s420506779
p00010
u024715419
1514430596
Python
Python3
py
Accepted
20
5684
484
import math n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) s = 0.5*((x1-x3)*(y2-y3) - (x2-x3)*(y1-y3)) a = (x2-x3)**2 + (y2-y3)**2 b = (x1-x3)**2 + (y1-y3)**2 c = (x2-x1)**2 + (y2-y1)**2 rx = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3)/(16*s**2) ry = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3)/(16*s**2) r = math.sqrt((rx-x1)**2 + (ry-y1)**2) print( "{0:.3f} {1:.3f} {2:.3f}".format(rx+0, ry+0, r+0))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,191
s966441617
p00010
u764789069
1514696958
Python
Python
py
Accepted
10
4792
827
n = int(raw_input()) i = 0 while (i < n): x1,y1,x2,y2,x3,y3=map(float,raw_input().split()) m1,m2=(x1+x2) / 2, (y1+y2) / 2 n1,n2=(x1+x3) / 2, (y1+y3) / 2 if y1==y2: a = 1 b = 0 c = m1 elif x1==x2: a = 0 b = 1 c = m2 else: a = (x2-x1) / (y2-y1) b = 1 c = m2+a*m1 if y1==y3: d = 1 e = 0 f = n1 elif x1==x3: d = 0 e = 1 f = n2 else: d = (x3-x1) / (y3-y1) e = 1 f = n2+d*n1 if a*d-b*c==0: print "not exist answer" else: x = (float((c*e-b*f)) / (a*e-b*d))+0 y = (float((a*f-c*d)) / (a*e-b*d))+0 print ('%.3f' % round(x,3)), ('%.3f' % round(y,3)), ('%.3f' % round(((((x - x1)**2+(y-y1)**2)**0.5)),3)) i += 1
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,192
s891334405
p00010
u273843182
1514981609
Python
Python3
py
Accepted
20
5672
432
import math N = int(input()) for i in range(N): x1,y1,x2,y2,x3,y3 = map(float,input().split()) x =((y1-y3)*(y1*y1 -y2*y2 +x1*x1 -x2*x2) -(y1-y2)*(y1*y1 -y3*y3 +x1*x1 -x3*x3)) / (2*((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))) y =((x1-x3)*(x1*x1 -x2*x2 +y1*y1 -y2*y2) -(x1-x2)*(x1*x1 -x3*x3 +y1*y1 -y3*y3)) / (2*((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))) r = (x-x1)*(x-x1)+(y-y1)*(y-y1) print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,math.sqrt(r)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,193
s516115277
p00010
u546285759
1516346062
Python
Python3
py
Accepted
20
5684
598
n = int(input()) for _ in range(n): x1, y1, x2, y2, x3, y3 = map(float, input().split()) a = pow((x3-x2) ** 2 + (y3-y2) ** 2, 0.5) b = pow((x3-x1) ** 2 + (y3-y1) ** 2, 0.5) c = pow((x1-x2) ** 2 + (y1-y2) ** 2, 0.5) cosA = (b**2 + c**2 - a**2) / (2*b*c) sinA = pow(1 - cosA**2, 0.5) R = a / sinA / 2 a, b, c = x1-x2, y1-y2, -(x1**2 + y1**2) + (x2**2 + y2**2) d, e, f = x2-x3, y2-y3, -(x2**2 + y2**2) + (x3**2 + y3**2) l = (c*e - b*f) / (e*a - b*d) m = (c*d - a*f) / (b*d - a*e) l, m = l*-0.5, m*-0.5 print("{:.3f} {:.3f} {:.3f}".format(l, m, R))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,194
s275837697
p00010
u043254318
1516383312
Python
Python3
py
Accepted
20
5688
445
import math N = int(input()) for l in range(N): x1,y1,x2,y2,x3,y3 = [float(i) for i in input().split()] # ax + by = e # cx + dy = f a,b,c = x1-x2, y1-y2, (x1-x2)*(x1+x2)/2 + (y1-y2)*(y1+y2)/2 d,e,f = x1-x3, y1-y3, (x1-x3)*(x1+x3)/2 + (y1-y3)*(y1+y3)/2 X = (c*e-f*b)/(a*e-b*d) Y = (f*a-c*d)/(a*e-b*d) R = math.sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1)) print(format(X, '.3f'), format(Y, '.3f'), format(R, '.3f'))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,195
s311357839
p00010
u150984829
1516782203
Python
Python3
py
Accepted
20
5684
285
for _ in[0]*int(input()): a,b,c,d,e,f=map(float,input().split()) x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d)) y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c)) print(f"{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}")
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,196
s265666860
p00010
u150984829
1516782465
Python
Python3
py
Accepted
20
5672
283
for _ in[0]*int(input()): a,b,c,d,e,f=map(float,input().split()) x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d)) y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c)) print('%.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,197
s766615770
p00010
u150984829
1516782566
Python
Python3
py
Accepted
20
5668
266
for _ in[0]*int(input()): a,b,c,d,e,f=map(float,input().split()) s,t,u=a*a+b*b,c*c+d*d,e*e+f*f x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d)) y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c)) print('%.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,198
s920772895
p00010
u150984829
1516783308
Python
Python3
py
Accepted
20
5672
274
import math for _ in[0]*int(input()): a,b,c,d,e,f=map(float,input().split()) s,t,u=a*a+b*b,c*c+d*d,e*e+f*f x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d)) y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c)) print('%.3f %.3f %.3f'%(x,y,math.hypot(x-a,y-b)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,199
s820563602
p00010
u069727578
1520044280
Python
Python
py
Accepted
10
4768
368
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)
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,200
s029881406
p00010
u166871988
1523704484
Python
Python3
py
Accepted
20
5688
425
import math n=int(input()) for i in range(n): x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()] A=math.hypot(x2-x3,y2-y3)**2 B=math.hypot(x1-x3,y1-y3)**2 C=math.hypot(x1-x2,y1-y2)**2 t1=A*(B+C-A) t2=B*(A+C-B) t3=C*(A+B-C) px=(t1*x1+t2*x2+t3*x3)/(t1+t2+t3) py=(t1*y1+t2*y2+t3*y3)/(t1+t2+t3) r=math.hypot(px-x1,py-y1) print("%.3f %.3f %.3f"%(round(px,3),round(py,3),round(r,3)))
p00010
<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>
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
5,201