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 stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s169277116 | p00009 | u706217959 | 1530692856 | Python | Python3 | py | Runtime Error | 0 | 0 | 535 | import
def prime_calc(n):
if n < 2:
return False
else:
i = 2
while n > i:
if n % i == 0:
return False
else:
i += 1
return True
def prime(n):
cnt = 0
for i in range(0, n+1):
ans = prime_calc(i)
if ans is True:
cnt = cnt + 1
return cnt
def main():
a = []
for line in sys.stdin:
a.append(int(line))
for line in a:
print(prime(line))
if __name__ == "__main__":
main()
|
s139759054 | p00009 | u706217959 | 1530693185 | Python | Python3 | py | Runtime Error | 0 | 0 | 788 | import argparse
def prime_calc(n):
if n < 2:
return False
else:
i = 2
while n > i:
if n % i == 0:
return False
else:
i += 1
return True
def prime(n):
cnt = 0
for i in range(0, n+1):
ans = prime_calc(i)
if ans is True:
cnt = cnt + 1
return cnt
def main():
l = []
parser = argparse.ArgumentParser()
parser.add_argument("filename", help="The filename to be processed")
args = parser.parse_args()
if args.filename:
with open(args.filename) as f:
for line in f:
a = int(line.rstrip())
l.append(a)
for line in l:
print(prime(line))
if __name__ == "__main__":
main()
|
s350167879 | p00009 | u894941280 | 1344960124 | Python | Python | py | Runtime Error | 0 | 1008 | 272 | t =[]
for n in range(2,10000):
for x in range(2,n):
if n % x == 0:
break
else:
t.append(n)
while True:
try:
b=0
a = int(input())
for b in range(10000):
if t[b] > a:
print len(t[0:b])
break
except EOFError:
break |
s133269875 | p00009 | u894941280 | 1345048556 | Python | Python | py | Runtime Error | 0 | 6040 | 262 | t = []
for a in range(2,10000):
for n in range(2,a):
if a % n == 0:
break
else:
t.append(a)
while True:
try:
z = int(input())
for w in range(1000000):
if t[w] > z:
break
print len(t[0:w])
except EOFError:
break |
s678806407 | p00009 | u894941280 | 1345122451 | Python | Python | py | Runtime Error | 0 | 1004 | 266 | t =[]
for n in range(2,10000):
for x in range(2,n):
if n % x == 0:
break
else:
t.append(n)
while True:
try:
a = int(input())
for b in range(100000):
if t[b] >= a:
break
print len((t[0:b]))
except EOFError:
break |
s575702993 | p00009 | u891318575 | 1346517229 | Python | Python | py | Runtime Error | 0 | 5020 | 423 | # -*- coding: utf-8 -*-
while True:
try:
n = int(raw_input())
list1 = range(2, n)
list2 = []
while True:
i = list1.pop(0)
list2.append(i)
for x in list1:
if x % i == 0:
list1.remove(x)
if i**2 > list1[::-1][0]:
break
print(len(list2 + list1))
except EOFError:
break |
s637527336 | p00009 | u891318575 | 1346517347 | Python | Python | py | Runtime Error | 0 | 5020 | 482 | # -*- coding: utf-8 -*-
while True:
try:
n = int(raw_input())
if n < 3:
print(0)
continue
list1 = range(2, n)
list2 = []
while True:
i = list1.pop(0)
list2.append(i)
for x in list1:
if x % i == 0:
list1.remove(x)
if i**2 > list1[::-1][0]:
break
print(len(list2 + list1))
except EOFError:
break |
s991199099 | p00009 | u647766105 | 1350991138 | Python | Python | py | Runtime Error | 0 | 5012 | 288 | import sys
n=10**5
s=[True]*n
s[0]=False
s[1]=False
for x in xrange(2, int(n**0.5)+1):
if s[x]:
for i in xrange(x+x,n,x):
s[i]=False
for x in sys.stdin.readlines():
x=int(x)
cnt=0
for i in xrange(x):
if s[i]:
cnt=cnt+1
print cnt |
s477330240 | p00009 | u647766105 | 1350991886 | Python | Python | py | Runtime Error | 0 | 5012 | 288 | import sys
n=10**5
s=[True]*n
s[0]=False
s[1]=False
for x in xrange(2, int(n**0.5)+1):
if s[x]:
for i in xrange(x+x,n,x):
s[i]=False
for x in sys.stdin.readlines():
a=int(x)
cnt=0
for i in xrange(a):
if s[i]:
cnt=cnt+1
print cnt |
s417080556 | p00009 | u647766105 | 1350991922 | Python | Python | py | Runtime Error | 0 | 5012 | 290 | import sys
n=10**5+1
s=[True]*n
s[0]=False
s[1]=False
for x in xrange(2, int(n**0.5)+1):
if s[x]:
for i in xrange(x+x,n,x):
s[i]=False
for x in sys.stdin.readlines():
a=int(x)
cnt=0
for i in xrange(a):
if s[i]:
cnt=cnt+1
print cnt |
s273490293 | p00009 | u647766105 | 1355063082 | Python | Python | py | Runtime Error | 0 | 5076 | 241 | import sys
n=10**5
p=[1]*n
p[0],p[1]=0,0
for i in xrange(2,int(n**0.5)+1):
if p[i]==1:
for j in xrange(i**2,n,i):
p[j]=0
for i in xrange(2,n):
p[i]+=p[i-1]
for line in sys.stdin.readlines():
print p[int(line)] |
s499220680 | p00009 | u585414111 | 1365444557 | Python | Python | py | Runtime Error | 0 | 0 | 238 | import sys
def f(n):
li = [x for x in range(2,n+1)]
pr = []
while True:
pr.append(li[0])
li = [x for x in li if x%li[0]!=0]
if li[-1]<pr[-1]**2: return pr+li
for n in sys.stdin:
print len(f(int(n))) |
s752816637 | p00009 | u912237403 | 1376789235 | Python | Python | py | Runtime Error | 0 | 0 | 849 | import math
def get_primes(max_number):#return prime list smaller than max_number
if max_number == 2:
return [2]
elif max_number < 3:
return []
numbers=range(1, max_number + 2, 2)
nroot=math.floor(max_number ** 0.5)
n=len(numbers)
numbers[0]=0
for i in range(1, n):
x = numbers[i]
if x > nroot:
break
if x and i + x < n:
for j in range(i+x,n+1,x):
numbers[j] = 0
x=[2] + filter(None, numbers[1:])
return x
n=[]
i=0
while (True):
try:
n.append([i,input(), 0])
i+=1
except:
break
n=sorted(n, key=lambda x: x[1])
for i, e in enumerate(get_primes(n[-1][1])):
for j in range(len(n)):
if e<=n[j][1]:
n[j][2]+=1
n=sorted(n, key=lambda x: x[0])
for e in n:
print e[2] |
s003345443 | p00009 | u511257811 | 1381947632 | Python | Python | py | Runtime Error | 0 | 0 | 299 | import sys
for line in sys.stdin:
count = 0
n = int(line)
nums = range(2, n+1)
while True:
if len(nums) == 1:
count += 1
break
else:
count += 1
nums = [ for x in nums[1:] if x % nums[0] != 0 ]
print count |
s988187479 | p00009 | u511257811 | 1381947922 | Python | Python | py | Runtime Error | 0 | 0 | 355 | import sys
for line in sys.stdin:
count = 0
n = int(line)
nums = range(2, n+1)
while True:
if len(nums) == 1:
count += 1
break
else:
count += 1
m = nums[0]
numsCandidate = [1:]
nums = [ for x in numsCandidate if x % m != 0 ]
print count |
s157717712 | p00009 | u511257811 | 1381948494 | Python | Python | py | Runtime Error | 0 | 0 | 404 | import sys
for line in sys.stdin:
count = 0
n = int(line)
nums = range(2, n+1)
while True:
if len(nums) == 0:
break
if len(nums) == 1:
count += 1
break
else:
count += 1
m = nums[0]
numsCandidate = nums[1:]
nums = [ for x in numsCandidate if x % m != 0 ]
print count |
s216715347 | p00009 | u511257811 | 1382032655 | Python | Python | py | Runtime Error | 0 | 0 | 307 | import math
import sys
nums = [1] * 1000000
nums[:2] = [0,0]
cnt = 0
while cnt <= math.sqrt(n):
flg = nums[cnt]
if flg == 1:
k = 2
while k*cnt <= n:
nums[k*cnt] = 0
k += 1
cnt += 1
for line in sys.stdin:
n = int(line)
print sum(nums[:n+1]) |
s328361170 | p00009 | u674319057 | 1382322805 | Python | Python | py | Runtime Error | 0 | 0 | 415 | #!/usr/bin/env python
def get_pn(num, result):
if num == 1:
return result
else:
for i in range(2,num-1):
if (num % i) == 0:
break
else:
result.append(num)
return get_pn(num-1, result)
if __name__ == "__main__":
while True:
try:
print len(get_pn(int(raw_input()),[]))
except EOFError:
break |
s102008727 | p00009 | u674319057 | 1382322858 | Python | Python | py | Runtime Error | 0 | 0 | 423 | #!/usr/bin/env python
def get_pn(num, result):
if num == 1:
return result
else:
for i in range(2,num-1):
if (num % i) == 0:
break
else:
result.append(num)
return get_pn(num-1, result)
if __name__ == "__main__":
for i in range(30):
try:
print len(get_pn(int(raw_input()),[]))
except EOFError:
break |
s606990577 | p00009 | u674319057 | 1382322946 | Python | Python | py | Runtime Error | 0 | 0 | 437 | #!/usr/bin/env python
def get_pn(num, result):
if (num == 1 or num == 0):
return result
else:
for i in range(2,num-1):
if (num % i) == 0:
break
else:
result.append(num)
return get_pn(num-1, result)
if __name__ == "__main__":
for i in range(30):
try:
print len(get_pn(int(raw_input()),[]))
except EOFError:
break |
s411382551 | p00009 | u674319057 | 1382323028 | Python | Python | py | Runtime Error | 0 | 0 | 425 | #!/usr/bin/env python
def get_pn(num, result):
if (num <= 1):
return result
else:
for i in range(2,num-1):
if (num % i) == 0:
break
else:
result.append(num)
return get_pn(num-1, result)
if __name__ == "__main__":
for i in range(30):
try:
print len(get_pn(int(raw_input()),[]))
except EOFError:
break |
s135046721 | p00009 | u674319057 | 1382323117 | Python | Python | py | Runtime Error | 0 | 0 | 423 | #!/usr/bin/env python
def get_pn(num, result):
if (num <= 1):
return result
else:
for i in range(2,num):
if (num % i) == 0:
break
else:
result.append(num)
return get_pn(num-1, result)
if __name__ == "__main__":
for i in range(30):
try:
print len(get_pn(int(raw_input()),[]))
except EOFError:
break |
s362151391 | p00009 | u245286435 | 1384412860 | Python | Python | py | Runtime Error | 0 | 0 | 350 | def isPrime(num):
flag = True
for i in range(2, num):
if num % i == 0:
flag = False
break
return flag
def countPrime(num):
count = 0
for i in range(2, num+1):
if isPrime(i):
count += 1
return count
if __name__ == '__main__':
nums = []
for num in sys.stdin:
nums.append(int(num))
for num in nums:
print countPrime(num) |
s802963582 | p00009 | u093607836 | 1384690275 | Python | Python | py | Runtime Error | 0 | 0 | 239 | import sys
rand = random.randint
def prime(n):
if n == 2: return True
if n < 2 or n & 1 == 0: return False
return pow(2, n-1, n) == 1
a = [prime(i) for i in range(1000000)]
for s in sys.stdin:
i = int(s)
print(a[:i+1].count(True)) |
s932853278 | p00009 | u124909914 | 1392355175 | Python | Python | py | Runtime Error | 0 | 0 | 362 | import math
ans = []
while True:
try:
n = int(raw_input())
isPrime = [-1] * (n + 1)
isPrime[0], isPrime[1] = False, False
i = 2
while i * i < n:
for j in range(i, n+i, i):
isPrime[j] = False
isPrime[i] = True
i = isPrime.index(-1)
ans.append(isPrime.count(True) + isPrime.count(-1))
except EOFError:
break
for num in ans:
print num |
s243087366 | p00009 | u633068244 | 1393352464 | Python | Python | py | Runtime Error | 0 | 0 | 262 | while True:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(1:n):
j = 2
while k < n:
k = i*j
filter[k-1] = 0
count = 0
do i in filter:
sum += i
print sum |
s242894424 | p00009 | u633068244 | 1393352522 | Python | Python | py | Runtime Error | 0 | 0 | 368 | while True:
try:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(1:n):
j = 2
while k < n:
k = i*j
filter[k-1] = 0
j += 1
count = 0
do i in filter:
sum += i
print sum
except:
break |
s650455368 | p00009 | u633068244 | 1393353410 | Python | Python | py | Runtime Error | 0 | 0 | 423 | while True:
while True:
try:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(2,n//2):
j = 2
k = i*j
while k < n:
filter[k-1] = 0
j += 1
k = i*j
print filter
sum = 0
for i in filter:
sum += i
print sum
except:
break |
s103520941 | p00009 | u633068244 | 1393353804 | Python | Python | py | Runtime Error | 0 | 0 | 473 | while True:
try:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(2,n//2):
if filter[i] = 1
j = 2
k = i*j
while k < n:
filter[k-1] = 0
j += 1
k = i*j
print filter
sum = 0
for i in filter:
sum += i
print sum
except:
break |
s245054720 | p00009 | u633068244 | 1393353821 | Python | Python | py | Runtime Error | 0 | 0 | 475 | while True:
try:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(2,n//2):
if filter[i] == 1:
j = 2
k = i*j
while k < n:
filter[k-1] = 0
j += 1
k = i*j
print filter
sum = 0
for i in filter:
sum += i
print sum
except:
break |
s749105086 | p00009 | u633068244 | 1393353872 | Python | Python | py | Runtime Error | 0 | 0 | 471 | while True:
try:
n = int(raw_input())
filter = [1 for i in range(n)]
filter[0] = 0
for i in range(2,n//2):
if filter[i] == 1:
j = 2
k = i*j
while k < n:
filter[k-1] = 0
j += 1
k = i*j
print filter
sum = 0
for i in filter:
sum += i
print sum
except:
break |
s641878696 | p00009 | u633068244 | 1393572657 | Python | Python | py | Runtime Error | 0 | 0 | 316 | import math
r = 999999
sqrt = int(math.sqrt(r))
prime = [1 for i in range(r)]
prime[0] = 0
for i in range(2,r/2):
prime[2*i-1] = 0
for i in range(3,sqrt,2):
for j in range(2*i,r,i)
prime[j] = 0
while True:
try:
n = int(raw_input())
print sum(prime[:n])
except:
break |
s096343074 | p00009 | u633068244 | 1393572945 | Python | Python | py | Runtime Error | 0 | 0 | 305 | import math
r = 999999
sqrt = int(math.sqrt(r))
prime = "1"*r
prime[0] = 0
for i in range(2,r/2):
prime[2*i-1] = 0
for i in range(3,sqrt,2):
for j in range(2*i,r+1,i):
prime[j-1] = 0
while True:
try:
n = int(raw_input())
print sum(prime[:n])
except:
break |
s832941235 | p00009 | u633068244 | 1393572965 | Python | Python | py | Runtime Error | 0 | 0 | 309 | import math
r = 999999
sqrt = int(math.sqrt(r))
prime = "1"*r
prime[0] = 0
for i in range(2,r/2):
prime[2*i-1] = "0"
for i in range(3,sqrt,2):
for j in range(2*i,r+1,i):
prime[j-1] = "0"
while True:
try:
n = int(raw_input())
print sum(prime[:n])
except:
break |
s494548464 | p00009 | u633068244 | 1393572977 | Python | Python | py | Runtime Error | 0 | 0 | 311 | import math
r = 999999
sqrt = int(math.sqrt(r))
prime = "1"*r
prime[0] = "0"
for i in range(2,r/2):
prime[2*i-1] = "0"
for i in range(3,sqrt,2):
for j in range(2*i,r+1,i):
prime[j-1] = "0"
while True:
try:
n = int(raw_input())
print sum(prime[:n])
except:
break |
s520063673 | p00009 | u633068244 | 1393574104 | Python | Python | py | Runtime Error | 0 | 0 | 445 | ----:---F1 *scratch* All L1 (Fundamental)------------------------------------------------------------------------------------
Loading subst-jis...done
import math
r = 999999
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*(i+1)-1,r,i+1):
p[j] = 0
while True:
try:
n = int(raw_input())
print sum(p[:n])
except:
break |
s625227796 | p00009 | u633068244 | 1393672642 | Python | Python | py | Runtime Error | 0 | 0 | 283 | import math
while True:
try:
n.append(int(raw_input()))
except:
break
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
for j in range(2*i+1,r,i+1):
p[j] = 0
for i in n:
print sum(p[:i]) |
s080727649 | p00009 | u633068244 | 1393676445 | Python | Python | py | Runtime Error | 0 | 0 | 288 | import math
n = []
while True:
try:
n.append(int(raw_input()))
except:
break
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
p[2*i+1::i+1] = range(2*i+1,r,i+1):
for i in n:
print sum(p[:i]) |
s970051253 | p00009 | u633068244 | 1393676473 | Python | Python | py | Runtime Error | 0 | 0 | 296 | import math
n = []
while True:
try:
n.append(int(raw_input()))
except:
break
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
p[2*i+1::i+1] = [0 for range(2*i+1,r,i+1)]:
for i in n:
print sum(p[:i]) |
s820984870 | p00009 | u633068244 | 1393676508 | Python | Python | py | Runtime Error | 0 | 0 | 293 | import math
n = []
while True:
try:
n.append(int(raw_input()))
except:
break
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
p[2*i+1::i+1] = [0 for range(2*i+1,r,i+1)]
for i in n:
print sum(p[:i]) |
s383093190 | p00009 | u633068244 | 1393676580 | Python | Python | py | Runtime Error | 0 | 0 | 289 | import math
n = []
while True:
try:
n.append(int(raw_input()))
except:
break
r = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
p[2*i+1::i+1] = [0]*range(2*i+1,r,i+1)
for i in n:
print sum(p[:i]) |
s060395458 | p00009 | u858885710 | 1393855129 | Python | Python | py | Runtime Error | 0 | 0 | 239 | import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a <= num:
if ifprime[a]:
ans += 1
b = a*a
while b <= num:
ifprime[b] = 0
b += a
a += 1
for n in sys.stdin:
print sum(ifprime[:int(n)]) |
s702221446 | p00009 | u193025715 | 1395307556 | Python | Python | py | Runtime Error | 0 | 0 | 389 | import math
val = []
max_prime = 0
while True:
num = int(raw_input())
tmp = [i+1 for i in range(1, num)]
x = math.sqrt(num)
if len(val) != 0:
max_prime = val[-1]
tmp = tmp[max_prime-1:]
print tmp
for i in tmp:
if i > x: break
for j in range(2,num):
if i*j > num: break
if i*j in tmp: tmp.remove(i*j)
val += tmp[len(val):]
print val
print max_prime
print len(tmp) |
s455093910 | p00009 | u633068244 | 1395996155 | Python | Python | py | Runtime Error | 0 | 0 | 177 | def isPrime(p):
if p == 2: return 1
if p < 2 or p&1 == 0: return 0
return 1 if pow(2,p-1,p) == 1 else 0
n = int(raw_input())
print sum(isPrime(int(i) for i in range(1,n+1)) |
s567473364 | p00009 | u633068244 | 1395996236 | Python | Python | py | Runtime Error | 0 | 0 | 194 | def isPrime(p):
if p == 2: return 1
if p < 2 or p&1 == 0: return 0
return 1 if pow(2,p-1,p) == 1 else 0
while True:
try:
n = int(raw_input())
print sum(isPrime(i) for i in range(1,n+1)) |
s578211264 | p00009 | u992434746 | 1401842270 | Python | Python3 | py | Runtime Error | 0 | 0 | 616 | # coding: utf-8
import sys
import math
if __name__ == '__main__':
input_list = sys.stdin.readlines()
for num in input_list:
target_number = int(num.replace('\n', ''))
serial_number_list = [r for r in range(2, target_number + 1)]
multiple_list = []
while math.sqrt(target_number) >= serial_number_list[0]:
serial_number = serial_number_list[0]
i = 1
multiple_list.append(serial_number)
while target_number >= serial_number * i:
if serial_number * i in serial_number_list:
serial_number_list.pop(serial_number_list.index(serial_number * i))
i += 1
print(multiple_list) |
s588522487 | p00009 | u992434746 | 1401842458 | Python | Python3 | py | Runtime Error | 0 | 0 | 637 | # coding: utf-8
import sys
import math
if __name__ == '__main__':
input_list = sys.stdin.readlines()
for num in input_list:
target_number = int(num.replace('\n', ''))
serial_number_list = [r for r in range(2, target_number + 1)]
multiple_list = []
while math.sqrt(target_number) >= serial_number_list[0]:
serial_number = serial_number_list[0]
i = 1
multiple_list.append(serial_number)
while target_number >= serial_number * i:
if serial_number * i in serial_number_list:
serial_number_list.pop(serial_number_list.index(serial_number * i))
i += 1
print(multiple_list + serial_number_list) |
s737736396 | p00009 | u992434746 | 1401842611 | Python | Python3 | py | Runtime Error | 0 | 0 | 642 | # coding: utf-8
import sys
import math
if __name__ == '__main__':
input_list = sys.stdin.readlines()
for num in input_list:
target_number = int(num.replace('\n', ''))
serial_number_list = [r for r in range(2, target_number + 1)]
multiple_list = []
while math.sqrt(target_number) >= serial_number_list[0]:
serial_number = serial_number_list[0]
i = 1
multiple_list.append(serial_number)
while target_number >= serial_number * i:
if serial_number * i in serial_number_list:
serial_number_list.pop(serial_number_list.index(serial_number * i))
i += 1
print(len(multiple_list + serial_number_list)) |
s541923543 | p00009 | u992434746 | 1401875803 | Python | Python3 | py | Runtime Error | 0 | 0 | 761 | import math
def sieve_of_erastosthenes(target_list):
for num in target_list:
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
print(sum(input_list))
break
for s in range(serial ** 2, num, serial):
input_list[s] = False
if __name__ == '__main__':
target_list = []
while True:
try:
target_list.append(int(input()))
except:
break
sieve_of_erastosthenes(target_list) |
s169099360 | p00009 | u992434746 | 1401876232 | Python | Python3 | py | Runtime Error | 0 | 0 | 697 | import math
def sieve_of_erastosthenes(num):
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
# print([i for i, b in enumerate(input_list) if b == True])
return sum(input_list)
for s in range(serial ** 2, num, serial):
input_list[s] = False
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
print(sieve_of_erastosthenes(n)) |
s598956866 | p00009 | u992434746 | 1401958316 | Python | Python3 | py | Runtime Error | 0 | 0 | 666 | import math
def sieve_of_erastosthenes(num):
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
return input_list
for s in range(serial ** 2, num, serial):
input_list[s] = False
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
input_list = sieve_of_erastosthenes(n)
print(sum(input_list)) |
s326236620 | p00009 | u992434746 | 1401958508 | Python | Python3 | py | Runtime Error | 0 | 0 | 701 | import math
def sieve_of_erastosthenes(num):
if 2 >= num:
return 1
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
return input_list
for s in range(serial ** 2, num, serial):
input_list[s] = False
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
input_list = sieve_of_erastosthenes(n)
print(sum(input_list)) |
s988089281 | p00009 | u992434746 | 1401958831 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | import math
def sieve_of_erastosthenes(num):
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
return input_list
for s in range(serial ** 2, num, serial):
input_list[s] = False
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
if 2 >= n:
print(1)
else:
input_list = sieve_of_erastosthenes(n)
print(sum(input_list)) |
s963301506 | p00009 | u992434746 | 1401959881 | Python | Python3 | py | Runtime Error | 0 | 0 | 456 | input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
sqrt = math.sqrt(num)
for serial in range(3, num, 2):
if serial >= sqrt:
return input_list
if input_list[serial] is True:
for s in range(serial ** 2, num, serial):
input_list[s] = False |
s772256971 | p00009 | u992434746 | 1402111184 | Python | Python3 | py | Runtime Error | 0 | 0 | 690 | def sieve_of_erastosthenes(num):
input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
input_list[0] = input_list[1] = False
input_list[2] = input_list[3] = input_list[5] = True
for serial in range(3, int(num ** 0.5) + 1, 2):
if input_list[serial] is True:
for s in range(serial ** 2, num, serial):
input_list[s] = False
# print([i for i, b in enumerate(input_list) if b == True])
return sum(input_list)
if __name__ == '__main__':
while True:
try:
n = int(input())
except:
break
print(sieve_of_erastosthenes(n)) |
s648969203 | p00010 | u995990363 | 1530789227 | Python | Python3 | py | Runtime Error | 0 | 0 | 588 | import math
def run():
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
u1 = (x1-x3)*(x2-x1)*(x3-x2)
u2 = (x2-x1)*(y3-y2)*(y3+y2)
u3 = (x3-x2)*(y2-y1)*(y2+y1)
v = x1*x2 + x2*y3 + x3*y1 - x1*y3 - x2*y1 + x3*y2
Py = (-u1 + u2 - u3) / v / 2
Px = (x2**2 - x1**2 + y2**2 - y1**2 - (y2 - y1)*Py) / (x2-x1) / 2
r = math.sqrt((Px-x1)**2 + (Py-y1)**2)
print('{0:.3f} {1:.3f} {2:.3f}'.format(round(Px,3), round(Py,3), round(r,3)))
if __name__ == '__main__':
run()
|
s701534005 | p00010 | u319725914 | 1534986400 | Python | Python3 | py | Runtime Error | 0 | 0 | 1070 | #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>
using namespace std;
#define reep(i, f, n) for (int i = f; i < n; ++i)
#define rep(i, n) reep(i, 0, n)
int main(){
float x1,x2,x3,y1,y2,y3,gx,gy,G,Xc,Yc,r;
int n;
scanf("%d", &n);
for (int i=0;i<n;i++) {
scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
gx = (x1+x2+x3)/3;
gy = (y1+y2+y3)/3;
G =( y2*x1-y1*x2 +y3*x2-y2*x3 +y1*x3-y3*x1 );
Xc = ((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(2*G);
Yc =-((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(2*G);
r = sqrt( (x1 - Xc) * (x1 - Xc) + (y1 - Yc) * (y1 - Yc) );
printf("%.3f %.3f %.3f\n", Xc, Yc, r);
}
return EXIT_SUCCESS;
}
|
s521544017 | p00010 | u244742296 | 1409819739 | Python | Python3 | py | Runtime Error | 0 | 0 | 1599 | import cmath
class Point(object):
def __init__(self, x, y):
self.point = complex(x, y)
def __str__(self):
return "x = {0}, y = {1}".format(self.point.real, self.point.imag)
class Triangle(Point):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)
# 角度を求める
def angle(A, B, C):
return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )
# 外接円の半径
def circumscribedCircleRadius(self):
return abs((self.edgeA/cmath.sin(self.angleA))/2)
# 外心
def circumscribedCircleCenter(self):
A = cmath.sin(2*self.angleA)
B = cmath.sin(2*self.angleB)
C = cmath.sin(2*self.angleC)
X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
return complex(X, Y)
line = list(map(float, input().split()))
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
T = Triangle(p1, p2, p3)
center = T.circumscribedCircleCenter()
print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius())) |
s065758709 | p00010 | u244742296 | 1409819859 | Python | Python3 | py | Runtime Error | 0 | 0 | 1624 | # -*- coding: utf-8 -*-
import cmath
class Point(object):
def __init__(self, x, y):
self.point = complex(x, y)
def __str__(self):
return "x = {0}, y = {1}".format(self.point.real, self.point.imag)
class Triangle(Point):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)
# 角度を求める
def angle(A, B, C):
return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )
# 外接円の半径
def circumscribedCircleRadius(self):
return abs((self.edgeA/cmath.sin(self.angleA))/2)
# 外心
def circumscribedCircleCenter(self):
A = cmath.sin(2*self.angleA)
B = cmath.sin(2*self.angleB)
C = cmath.sin(2*self.angleC)
X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
return complex(X, Y)
line = list(map(float, input().split()))
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
T = Triangle(p1, p2, p3)
center = T.circumscribedCircleCenter()
print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius())) |
s557884869 | p00010 | u244742296 | 1409819942 | Python | Python3 | py | Runtime Error | 0 | 0 | 1511 | # -*- coding: utf-8 -*-
import cmath
class Point(object):
def __init__(self, x, y):
self.point = complex(x, y)
def __str__(self):
return "x = {0}, y = {1}".format(self.point.real, self.point.imag)
class Triangle(Point):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)
def angle(A, B, C):
return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )
def circumscribedCircleRadius(self):
return abs((self.edgeA/cmath.sin(self.angleA))/2)
def circumscribedCircleCenter(self):
A = cmath.sin(2*self.angleA)
B = cmath.sin(2*self.angleB)
C = cmath.sin(2*self.angleC)
X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
return complex(X, Y)
line = list(map(float, input().split()))
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
T = Triangle(p1, p2, p3)
center = T.circumscribedCircleCenter()
print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius())) |
s033707512 | p00010 | u244742296 | 1409824731 | Python | Python3 | py | Runtime Error | 0 | 0 | 1624 | # -*- coding: utf-8 -*-
import cmath
class Point(object):
def __init__(self, x, y):
self.point = complex(x, y)
def __str__(self):
return "x = {0}, y = {1}".format(self.point.real, self.point.imag)
class Triangle(Point):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
# 3辺の長さ
self.edgeA = abs(b.point-c.point)
self.edgeB = abs(c.point-a.point)
self.edgeC = abs(a.point-b.point)
# 3角の大きさ
self.angleA = Triangle.angle(self.edgeA, self.edgeB, self.edgeC)
self.angleB = Triangle.angle(self.edgeB, self.edgeC, self.edgeA)
self.angleC = Triangle.angle(self.edgeC, self.edgeA, self.edgeB)
# 角度を求める
def angle(A, B, C):
return cmath.acos( (B*B+C*C-A*A)/(2*B*C) )
# 外接円の半径
def circumscribedCircleRadius(self):
return abs((self.edgeA/cmath.sin(self.angleA))/2)
# 外心
def circumscribedCircleCenter(self):
A = cmath.sin(2*self.angleA)
B = cmath.sin(2*self.angleB)
C = cmath.sin(2*self.angleC)
X = (self.a.point.real*A + self.b.point.real*B + self.c.point.real*C) / (A+B+C)
Y = (self.a.point.imag*A + self.b.point.imag*B + self.c.point.imag*C) / (A+B+C)
return complex(X, Y)
line = list(map(float, input().split()))
p1 = Point(line[0], line[1])
p2 = Point(line[2], line[3])
p3 = Point(line[4], line[5])
T = Triangle(p1, p2, p3)
center = T.circumscribedCircleCenter()
print("{0:.4f} {1:.4f} {2:.4f}".format(center.real, center.imag, T.circumscribedCircleRadius())) |
s988774061 | p00010 | u772921135 | 1417035034 | Python | Python | py | Runtime Error | 0 | 0 | 412 | # coding: UTF-8
# main.py
import math
t = map(int,raw_input().split())
for i in xrange(0,t[0]):
x1,x2,x3,y1,y2,y3 = map(float,raw_input().split())
a = x1-x2
b = y1-y2
c = -(x1*x1 + y1*y1 - x2*x2 - y2*y2)
d = x2-x3
e = y2-y3
f = -(x2*x2 + y2*y2 - x3*x3 - y3*y3)
l = (c*e - b*f)/(a*e - b*d)
m = (d*c - a*f)/(d*b - e*a)
n = -(x1*x1 + y1*y1 + l*x1 + m*y1)
print l*-0.5,m*-0.5,math.sqrt(l*l+m*m-n*4.0)/2.0 |
s911095464 | p00010 | u567380442 | 1424177241 | Python | Python3 | py | Runtime Error | 0 | 0 | 729 | import sys
def take2(iterable):
while True:
yield next(iterable), next(iterable)
#外積
def cross(v1, v2):
return v1.real * v2.imag - v1.imag * v2.real
# 線分13と線分24の交点を求める
def get_intersection(p1,p2,p3,p4):
a1 = p4 - p2
b1 = p2 - p3
b2 = p1 - p2
s1 = cross(a1, b2) / 2
s2 = cross(a1, b1) / 2
return p1 + (p3 - p1) * s1 / (s1 + s2)
n = int(f.readline())
for i in range(n):
p1, p2, p3 = [x + y * 1j for x, y in take2(map(float, f.readline().split()))]
p12 = (p1 + p2) / 2
p13 = (p1 + p3) / 2
pxy = get_intersection(p12,p13,p12 + (p2 - p1) * 1j,p13 + (p1 - p3) * 1j)
r = abs(pxy - p1)
print('{:.3f} {:.3f} {:.3f}'.format(pxy.real,pxy.imag,r)) |
s314705763 | p00010 | u540744789 | 1425718881 | Python | Python | py | Runtime Error | 0 | 0 | 706 | import math
for i in range(input()):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
if y2==y1 or y3==y1:
if y2==y1:
a2=-(x2-x1)/(y3-y1)
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f,=1,0,(x1+x2)/2,1,-a2,b2
else:
a1=-(x2-x1)/(y2-y1)
b1=((y2+y1)-a2*(x1+x2))/2
a,b,c,d,e,f,=1,-a1,b1,1,0,(x1+x3)/2
else:
a1=-(x2-x1)/(y2-y1)
a2=-(x3-x1)/(y3-y1)
b1=((y2+y1)-a1*(x1+x2))/2
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f,=1,-a1,b1,1,-a2,b2
py=(a*f-c*d)/(a*e-b*d)
px=(c*e-f*b)/(a*e-b*d)
r=math.sqrt((px-x1)**2 + (py-y1)**2)
print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r) |
s508923881 | p00010 | u540744789 | 1425719262 | Python | Python | py | Runtime Error | 0 | 0 | 706 | import math
for i in range(input()):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
if y2==y1 or y3==y1:
if y2==y1:
a2=-(x3-x1)/(y3-y1)
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f,=0,1,(x1+x2)/2,-a2,1,b2
else:
a1=-(x2-x1)/(y2-y1)
b1=((y2+y1)-a2*(x1+x2))/2
a,b,c,d,e,f,=-a1,1,b1,0,1,(x1+x3)/2
else:
a1=-(x2-x1)/(y2-y1)
a2=-(x3-x1)/(y3-y1)
b1=((y2+y1)-a1*(x1+x2))/2
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f,=-a1,1,b1,-a2,1,b2
py=(a*f-c*d)/(a*e-b*d)
px=(c*e-f*b)/(a*e-b*d)
r=math.sqrt((px-x1)**2 + (py-y1)**2)
print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r) |
s585418388 | p00010 | u540744789 | 1425719649 | Python | Python | py | Runtime Error | 0 | 0 | 703 | import math
for i in range(input()):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
if y2==y1 or y3==y1:
if y2==y1:
a2=-(x3-x1)/(y3-y1)
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f=0,1,(x1+x2)/2,-a2,1,b2
else:
a1=-(x2-x1)/(y2-y1)
b1=((y2+y1)-a2*(x1+x2))/2
a,b,c,d,e,f=-a1,1,b1,0,1,(x1+x3)/2
else:
a1=-(x2-x1)/(y2-y1)
a2=-(x3-x1)/(y3-y1)
b1=((y2+y1)-a1*(x1+x2))/2
b2=((y3+y1)-a2*(x1+x3))/2
a,b,c,d,e,f=-a1,1,b1,-a2,1,b2
py=(a*f-c*d)/(a*e-b*d)
px=(c*e-f*b)/(a*e-b*d)
r=math.sqrt((px-x1)**2 + (py-y1)**2)
print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r) |
s784666888 | p00010 | u379956761 | 1434726644 | Python | Python3 | py | Runtime Error | 0 | 0 | 568 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
n = int(input())
for data in sys.stdin:
if n <= 0:
break
n--
x1, y1, x2, y2, x3, y3 = map(float, data.split())
a1 = x2 - x1
b1 = y2 - y1
a2 = x3 - x1
b2 = y3 - y1
px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
r = math.sqrt(px * px + py * py)
px += x1
py += y1
print("{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)) |
s322827297 | p00010 | u722431421 | 1439541980 | Python | Python | py | Runtime Error | 0 | 0 | 494 | # coding: utf-8
#Problem Name: Circumscrived Circle of a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp
n = int(raw_input())
data = [0 for _ in range(n)]
for i in range(n):
data[i] = map(float,raw_input().split(' '))
for (x1,y1,x2,y2,x3,y3) in data:
det = 4*x2*y3 - 4*y2*x3
px = ((x2**2 + y2**2)*2*y3 - (x3**2 + y3**2)*2*y2)/det
py = (2*x2*(x3**2 + y3**2) - 2*x3*(x2**2 + y2**2))/det
r = ((px-x1)**2 + (py-y1)**2)**.5
print '{0:.3f} {1:.3f} {2:.3f}'.format(px,py,r) |
s955385463 | p00010 | u560214129 | 1450423270 | Python | Python3 | py | Runtime Error | 0 | 0 | 476 | import math
n = int(input())
i = 0
while i < n:
x1, y1, x2, y2, x3, y3 = map(float,input().split())
a = x2 - x1
b = y2 - y1
c = x3 - x1
d = y3 - y1
e = a * (x1 + x2) + b * (y1 + y3)
f = c * (x1 + x2) + d * (y1 + y3)
g = 2.0 * (a * (y3 - y2) - b * (x3 - x2))
if g == 0:
exit()
px = (d * e - b * f) / g
py = (a * f - c * e) / g
radius = ( (py - y1)*(py - y1) + (px - x1)*(px - x1) )
print("%.3f %.3f %.3f"%(px,py,math.sqrt(radius))) |
s748816088 | p00010 | u650459696 | 1456727214 | Python | Python3 | py | Runtime Error | 0 | 0 | 578 | def circum(x1,x2,x3,y1,y2,y3):
a1 = 2 * (x2 - x1)
b1 = 2 * (y2 - y1)
c1 = x1 ** 2 - x2 ** 2 + y1 **2 - y2 ** 2
a2 = 2 * (x3 - x1)
b2 = 2 * (y3 - y1)
c2 = x1 ** 2 - x3 ** 2 + y1 **2 - y3 ** 2
X = (b1 * c2 - b2 * c1)/(a1 * b2 - a2 * b1)
Y = (c1 * a2 - c2 * a1)/(a1 * b2 - a2 * b1)
R = ((x1 - X) ** 2 + (y1 - Y) ** 2) ** 0.5
return map(lambda n: round(n,3), [X,Y,R])
N = int(input())
ans = []
for i in range(N):
ans.append(circum(*list(map(float,input().split()))))
for i in range(N):
print('{0:.3f} {1:.3f} {2:.3f}'.format(*ans[i])) |
s564589367 | p00010 | u915343634 | 1459349526 | Python | Python3 | py | Runtime Error | 0 | 0 | 485 | import sys
import math
if sys.version_info[0] >= 3:
raw_input = input
N = int(raw_input())
for i in range(N):
x1, y1, x2, y2, x3, y3 = [float(e) for e in raw_input().split()]
a1 = 2*x2 - 2*x1
b1 = 2*y2 - 2*y1
c1 = x1**2 - x2**2 + y1**2 - y2**2
a2 = 2 * x3 - 2 * y1
b2 = 2 * y3 - 2 * y1
c2 = x1**2 - x3**2 + y1**2 - y3**2
x = (b1*c2-b2*c1)/(a1*b2-a2*b1)
y = (c1*a2-c2*a1)/(a1*b2-a2*b1)
print("%.3f %.3f %.3f" %(x, y, math.hypot(x1-x, y1-y))) |
s745746882 | p00010 | u966364923 | 1460036436 | Python | Python3 | py | Runtime Error | 0 | 0 | 1629 | def perpendicular_bisector(p, q):
x = (q[0] - p[0])
y = (q[1] - p[1])
return (2 * x, 2 * y, -x**2 - y**2)
def gauss_jordan_elimination(Array):
# N???M??????Array
N = len(Array)
if N == 0:
return (True, Array)
else:
M = len(Array[0])
A = []
for i in range(len(Array)):
A.append(Array[i][:])
pivot = 0
L = min(N, M)
while pivot < L:
pivot_v = A[pivot][pivot]
pivot_row = pivot
for i in range(pivot + 1, L):
v = max(A[i][pivot], -A[i][pivot])
if pivot_v < v:
pivot_row = i
pivot_v = v
if pivot_row > pivot:
for i in range(M):
A[pivot][i], A[pivot_row][i] = A[pivot_row][i], A[pivot][i]
if pivot_v == 0:
return ('False', A)
inv_pivot = 1 / A[pivot][pivot]
A[pivot][pivot] = 1
for i in range(pivot + 1, M):
A[pivot][i] *= inv_pivot
for i in range(N):
if i == pivot:
continue
t = -1 * A[i][pivot]
A[i][pivot] = 0
for j in range(pivot + 1, M):
A[i][j] += t * A[pivot][j]
pivot += 1
return ('True', A)
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(int, input().split())
a = list(perpendicular_bisector((x1, y1), (x2, y2)))
b = list(perpendicular_bisector((x1, y1), (x3, y3)))
c = [a, b]
state, c = gauss_jordan_elimination(c)
x = c[0][2]
y = c[1][2]
r = ((x - x1)**2 + (y - y1)**2)**0.5
print(round(x, 3), round(y, 3), round(r, 3)) |
s465297109 | p00010 | u146816547 | 1469285189 | Python | Python | py | Runtime Error | 0 | 0 | 488 | import math
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())
px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)))
py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)))
r = math.sqrt(pow((x1 - px), 2) + pow((y1 - py), 2))
print "%.4f %.4f %.4f" % (px, py, r) |
s976251197 | p00010 | u146816547 | 1469285290 | Python | Python | py | Runtime Error | 0 | 0 | 488 | import math
n = int(raw_input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())
px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)))
py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)))
r = math.sqrt(pow((x1 - px), 2) + pow((y1 - py), 2))
print "%.3f %.3f %.3f" % (px, py, r) |
s518084268 | p00010 | u813534019 | 1477494834 | Python | Python | py | Runtime Error | 0 | 0 | 494 | import math
x1=0
y1=1
x2=2
y2=3
x3=4
y3=5
n = input()
for _ in xrange(n):
p = map(float, raw_input().split())
A = p[x1]**2 - p[x2]**2 + p[y1]**2 - p[y2]**2
B = 2*p[x1] - 2*p[x2]
C = 2*p[y1] - 2*p[y2]
D = p[x1]**2 - p[x3]**2 + p[y1]**2 - p[y3]**2
E = 2*p[x1] - 2*p[x3]
F = 2*p[y1] - 2*p[y3]
b = (A*E-D*B)/(C*E-B*F)
a = (A*E-C*E*b)/(B*E)
r = math.sqrt( (p[x1]-a)**2 + (p[y1]-b)**2 )
print "%.3f %.3f %.3f" % (round(a, 3), round(b, 3), round(r, 3))
|
s841143812 | p00010 | u776559258 | 1477560284 | Python | Python3 | py | Runtime Error | 0 | 0 | 211 | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[int(i) for i in input().split()]
px=(x1+x2+x3)/3
py=(y1+y2+y3)/3
r=math.sqrt((x1-px)**2+(y1-py)**2)
print(round(px,3),round(py,3),round(r,3)) |
s412278712 | p00010 | u776559258 | 1477560503 | Python | Python3 | py | Runtime Error | 0 | 0 | 220 | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[int(i) for i in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) |
s899926985 | p00010 | u776559258 | 1477560544 | Python | Python3 | py | Runtime Error | 0 | 0 | 220 | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[int(j) for j in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) |
s115789405 | p00010 | u776559258 | 1477560612 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | import math
n=int(input())
for i in range(n):
(x1,y1,x2,y2,x3,y3)=[int(j) for j in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) |
s226022657 | p00010 | u776559258 | 1477560717 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
p_x=(x1+x2+x3)/3
p_y=(y1+y2+y3)/3
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) |
s416847749 | p00010 | u776559258 | 1477560755 | Python | Python3 | py | Runtime Error | 0 | 0 | 226 | import math
n=int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3=[float(i) for i in input().split()]
p_x=(x1+x2+x3)/3.0
p_y=(y1+y2+y3)/3.0
r=math.sqrt((x1-p_x)**2+(y1-p_y)**2)
print(round(p_x,3),round(p_y,3),round(r,3)) |
s325666559 | p00010 | u149199817 | 1478146799 | Python | Python3 | py | Runtime Error | 0 | 0 | 1425 | # -*- coding: utf-8 -*-
import sys
def length(a, b):
return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5
def solve_sim_equ(a, b, c, d, e, f):
'''
From Problem 0004.
This function solves following equation.
ax + by = c
dx + ey = f
'''
if a==0 and d==0:
if b==0 and e==0:
return 0., 0.
if b != 0:
return 0., c/b+0.
else:
return 0., f/e+0.
elif b==0 and e==0:
if a != 0:
return 0., d/a+0.
else:
return 0., a/d+0.
if b == 0:
a, d = d, a
b, e = e, b
c, f = f, c
g = e / b
x = (g*c - f) / (g*a - d)
y = (c - a*x) / b
return x+0., y+0.
def circumscribed_circle(x, y, z):
def get_equ_coef(p, q):
h_x = (p[0] + q[0]) / 2
h_y = (p[1] + q[1]) / 2
a = q[1] - p[1]
b = p[0] - q[0]
c = b * h_x - a * h_y
return b, -a, c
coef = get_equ_coef(x, y) + get_equ_coef(y, z)
center = solve_sim_equ(*coef)
r = length(center, x)
return center, r
def main():
N = int(input())
for i in range(N):
vs = [float(v) for v in input().split()]
a = (vs[0], vs[1])
b = (vs[2], vs[3])
c = (vs[4], vs[5])
center, r = circumscribed_circle2(a, b, c)
print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))
if __name__ == '__main__':
main() |
s305419532 | p00010 | u149199817 | 1478146830 | Python | Python3 | py | Runtime Error | 0 | 0 | 1425 | # -*- coding: utf-8 -*-
import sys
def length(a, b):
return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5
def solve_sim_equ(a, b, c, d, e, f):
'''
From Problem 0004.
This function solves following equation.
ax + by = c
dx + ey = f
'''
if a==0 and d==0:
if b==0 and e==0:
return 0., 0.
if b != 0:
return 0., c/b+0.
else:
return 0., f/e+0.
elif b==0 and e==0:
if a != 0:
return 0., d/a+0.
else:
return 0., a/d+0.
if b == 0:
a, d = d, a
b, e = e, b
c, f = f, c
g = e / b
x = (g*c - f) / (g*a - d)
y = (c - a*x) / b
return x+0., y+0.
def circumscribed_circle(x, y, z):
def get_equ_coef(p, q):
h_x = (p[0] + q[0]) / 2
h_y = (p[1] + q[1]) / 2
a = q[1] - p[1]
b = p[0] - q[0]
c = b * h_x - a * h_y
return b, -a, c
coef = get_equ_coef(x, y) + get_equ_coef(y, z)
center = solve_sim_equ(*coef)
r = length(center, x)
return center, r
def main():
N = int(input())
for i in range(N):
vs = [float(v) for v in input().split()]
a = (vs[0], vs[1])
b = (vs[2], vs[3])
c = (vs[4], vs[5])
center, r = circumscribed_circle2(a, b, c)
print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))
if __name__ == '__main__':
main() |
s110186981 | p00010 | u252368621 | 1479000112 | Python | Python3 | py | Runtime Error | 0 | 0 | 591 | import math
deta=[float(i) for i in input().split()]
h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)
h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)
h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)
sub=(h1+h2+h3)/2
s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))
sum=((h1*h2*h3)/s)/4
a=2*deta[2]-2*deta[0]
b=2*deta[3]-2*deta[1]
c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))
d=2*deta[4]-2*deta[2]
e=2*deta[5]-2*deta[3]
f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))
x=(e*c-b*f)/(a*e-b*d)
y=(a*f-c*d)/(a*e-b*d)
print("{0:.3f} {1:.3f} {2:.3f}".format(x,y,sum)) |
s024682548 | p00010 | u011621222 | 1490023512 | Python | Python | py | Runtime Error | 0 | 0 | 413 | from math import sqrt
n=input()
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
B1=2*(y2-y1)
C1=x2**2+y2**2-x1**2-y1**2
x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1))
a=sqrt((x2-x1)**2+(y2-y1)**2)
b=sqrt((x3-x1)**2+(y3-y1)**2)
c=sqrt((x3-x2)**2+(y3-y2)**2)
p=(a+b+c)/2
S=sqrt(p*(p-a)*(p-b)*(p-c))
R=a*b*c/4/S
print"%.3f %.3f %.3f"%(x,y,R) |
s742648167 | p00010 | u011621222 | 1490023638 | Python | Python | py | Runtime Error | 0 | 0 | 234 | from math import sqrt
n=input()
for i in range(n):
x1,y1,x2,y2,x3,y3=map(float,raw_input().split())
A1=2*(x2-x1)
B1=2*(y2-y1)
C1=x2**2+y2**2-x1**2-y1**2
x=((C1*B2)-(C2*B1))/((A1*B2)-(A2*B1))
y=((A1*C2)-(A2*C1))/((A1*B2)-(A2*B1)) |
s424874268 | p00010 | u011621222 | 1490023736 | Python | Python | py | Runtime Error | 0 | 0 | 218 | 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 |
s372109148 | p00010 | u797673668 | 1490620798 | Python | Python3 | py | Runtime Error | 0 | 0 | 623 | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
print(cx1, cy1, z1, cx2, cy2, z2)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r))) |
s765675391 | p00010 | u797673668 | 1490620884 | Python | Python3 | py | Runtime Error | 0 | 0 | 585 | import fractions
def calc(x1, y1, x2, y2):
return 2 * (x2 - x1), 2 * (y2 - y1), x2 ** 2 + y2 ** 2 - x1 ** 2 - y1 ** 2
n = int(input())
for _ in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
cx1, cy1, z1 = calc(x1, y1, x2, y2)
cx2, cy2, z2 = calc(x1, y1, x3, y3)
gcd = fractions.gcd(cx1, cx2)
r1, r2 = cx2 // gcd, cx1 // gcd
dcy = r1 * cy1 - r2 * cy2
dz = r1 * z1 - r2 * z2
y = dz / dcy
x = (z1 - cy1 * y) / cx1
r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
print(*map(lambda x: '{:.3f}'.format(round(x, 3)), (x, y, r))) |
s066672060 | p00010 | u868716420 | 1493773116 | Python | Python3 | py | Runtime Error | 0 | 0 | 706 | from math import sqrt
for _ in range(int(input())) :
x1, y1, x2, y2, x3, y3 = [float(temp) for temp in input().split()]
a = [x1, y1, (x1 ** 2) + (y1 ** 2)]
b = [x2, y2, (x2 ** 2) + (y2 ** 2)]
c = [x3, y3, (x3 ** 2) + (y3 ** 2)]
a1 = [(b[0] - a[0]), (b[1] - a[1]), (b[2] - a[2])]
b1 = [(c[0] - a[0]), (c[1] - a[1]), (c[2] - a[2])]
a1[1], a1[2] = (a1[1] / a1[0]), (a1[2] / a1[0])
b1[1], b1[2] = (b1[1] / b1[0]), (b1[2] / b1[0])
m = -(a1[2] - b1[2]) / (a1[1] - b1[1])
l = -(a1[1] * m + a1[2])
n = -((l * a[0]) + (m * a[1]) + a[2])
px = -l / 2
py = -m / 2
r = sqrt(((l / 2) ** 2)+((m / 2) ** 2)+n)
print('{:0.3f} {:0.3f} {:0.3f}'.format(px, py, r)) |
s655692986 | p00010 | u957021183 | 1504763070 | Python | Python3 | py | Runtime Error | 0 | 0 | 985 | # Aizu Problem 0010: Circumscribed Circle of a Triangle
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def circumscribed_circle(x1, y1, x2, y2, x3, y3):
d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
px = ( (x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
py = ( (x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
A = .5 * abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y1 - y1))
a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
r = a * b * c / (4 * A)
return px, py, r
N = int(input())
for k in range(N):
x1, y1, x2, y2, x3, y3 = [float(_) for _ in input().split()]
px, py, r = circumscribed_circle(x1, y1, x2, y2, x3, y3)
print("%.3f %.3f %.3f" % (px, py, r)) |
s842545166 | p00010 | u395334793 | 1505643997 | Python | Python | py | Runtime Error | 0 | 0 | 305 | 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)) |
s386945215 | p00010 | u933096856 | 1505825731 | Python | Python3 | py | Runtime Error | 0 | 0 | 235 | for i in range(n):
x1,y1,x2,y2,x3,y3=map(float, input().split())
x4,y4=0.5*(x2+x3), 0.5*(y2+y3)
xg,yg=2/3*(2*x1+x4), 2/3*(2*y1+y4)
xo,yo=(x1+x2+x3)/3, (y1+y2+y3)/3
r=((xo-x1)**2+(yo-y1)**2)**0.5
print(xg, yg, r) |
s456535820 | p00010 | u548155360 | 1512388589 | Python | Python3 | py | Runtime Error | 0 | 0 | 1911 | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
print(points_list)
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1 / a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) |
s815708549 | p00010 | u548155360 | 1512388703 | Python | Python3 | py | Runtime Error | 0 | 0 | 1909 | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
print(points_list)
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) |
s856122872 | p00010 | u548155360 | 1512388745 | Python | Python3 | py | Runtime Error | 0 | 0 | 1882 | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) |
s024542183 | p00010 | u548155360 | 1512394837 | Python | Python3 | py | Runtime Error | 0 | 0 | 2200 | # coding=utf-8
import math
if __name__ == '__main__':
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
points_list = [[x1, y1], [x2, y2], [x3, y3]]
points_list.sort()
if points_list[0][0] == points_list[1][0]:
py = (points_list[0][1] + points_list[1][1])/2
if points_list[2][1] == points_list[0][1]:
px = (points_list[0][0] + points_list[2][0])/2
else:
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
elif points_list[1][0] == points_list[2][0]:
py = (points_list[1][1] + points_list[2][1])/2
if points_list[2][1] == points_list[0][1]:
px = (points_list[0][0]+points_list[2][0])/2
else:
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m13x = (points_list[0][0] + points_list[2][0])/2
m13y = (points_list[0][1] + points_list[2][1])/2
b2 = m13y - a2*m13x
px = (py - b2)/a2
else:
a1_s = (points_list[1][1] - points_list[0][1])/(points_list[1][0] - points_list[0][0])
a1 = -1/a1_s
a2_s = (points_list[2][1] - points_list[0][1])/(points_list[2][0] - points_list[0][0])
a2 = -1/a2_s
m12x = (points_list[0][0] + points_list[1][0]) / 2
m12y = (points_list[0][1] + points_list[1][1]) / 2
m13x = (points_list[0][0] + points_list[2][0]) / 2
m13y = (points_list[0][1] + points_list[2][1]) / 2
b1 = m12y - a1 * m12x
b2 = m13y - a2 * m13x
px = (b2 - b1)/(a1 - a2)
py = a1*px + b1
r = math.sqrt(math.pow((px-points_list[0][0]), 2) + math.pow((py-points_list[0][1]), 2))
print('{0:.3f} {1:.3f} {2:.3f}'.format(px, py, r)) |
s209276934 | p00010 | u150984829 | 1516781312 | Python | Python3 | py | Runtime Error | 0 | 0 | 270 | for _ in[0]*int(input()):
a,b,c,d,e,f=map(int,input().split())
x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
y=((a*a+b*b)*(c-d)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
print(f"{x:.4} {y:.4} {(x*x+y*y)**.5:.4}")
|
s645411869 | p00010 | u150984829 | 1516782443 | Python | Python3 | py | Runtime Error | 0 | 0 | 282 | 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))
|
s493329395 | p00010 | u150984829 | 1516782714 | Python | Python3 | py | Runtime Error | 0 | 0 | 275 | 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)))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.