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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s844278401 | p02381 | u213265973 | 1494482145 | Python | Python3 | py | Runtime Error | 0 | 0 | 231 | import math
while True:
n = int(input())
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / float(n)
if n == 0:
break
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / float(n) ) |
s401391156 | p02381 | u213265973 | 1494482172 | Python | Python3 | py | Runtime Error | 0 | 0 | 235 | import math
while True:
n = int(input())
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / float(n)
if n == 0:
break
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / float(n) ) |
s781295569 | p02381 | u213265973 | 1494482207 | Python | Python3 | py | Runtime Error | 0 | 0 | 235 | import math
while True:
n = int(input())
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / float(n)
if n == 0:
break
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / float(n) ) |
s260288673 | p02381 | u213265973 | 1494482245 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | import math
while True:
n = int(input())
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / n
if n == 0:
break
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n ) |
s977167149 | p02381 | u213265973 | 1494482291 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | import math
while True:
n = int(input())
if n == 0:
break
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / n
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n ) |
s052578065 | p02381 | u213265973 | 1494482432 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | import math
while True:
n = int(input())
if n == 0:
break
score = [int(i) for i in input().split(" ")]
average = sum(score) / n
print("{:.8f}".format(math.sqrt(sum([(x-average) ** 2]) / n ) |
s197701469 | p02381 | u213265973 | 1494482487 | Python | Python3 | py | Runtime Error | 0 | 0 | 197 | import math
while True:
n = int(input())
if n == 0:
break
s = [int(i) for i in input().split(" ")]
m = sum(s) / n
print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2]) / n ) |
s679335420 | p02381 | u213265973 | 1494482499 | Python | Python3 | py | Runtime Error | 0 | 0 | 196 | import math
while True:
n = int(input())
if n == 0:
break
s = [int(i) for i in input().split(" ")]
m = sum(s) / n
print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2]) / n) |
s606347766 | p02381 | u213265973 | 1494482754 | Python | Python3 | py | Runtime Error | 0 | 0 | 207 | import math
while True:
n = int(input())
if n == 0:
break
s = [int(i) for i in input().split(" ")]
m = sum(s) / n
print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2 for x in s]) / n) |
s940283587 | p02381 | u603049633 | 1495866492 | Python | Python3 | py | Runtime Error | 0 | 0 | 237 | import math
def hensa(n, S):
m = sum(S)/n
x = 0
for i in S:
x += (i - m) ** 2
hensa = math.sqrt(x / n)
return hensa
n = 1
while n != 0:
n = int(input())
S = list(map(int, input().split()))
print("{0:04f}".format(hensa(n, S))) |
s415686525 | p02381 | u650790815 | 1496461163 | Python | Python3 | py | Runtime Error | 0 | 0 | 119 | n = int(input())
d = list(map(int,input().split()))
import math
m = sum(d) / n
print(math.sqrt( (x-m)**2/n for x in d)) |
s609309628 | p02381 | u350064373 | 1501147315 | Python | Python3 | py | Runtime Error | 0 | 0 | 166 | import statistics
while True:
x = input()
if x == 0:
break
else:
ls = list(map(int, input().split()))
print(statistics.pstdev(ls)) |
s049054554 | p02381 | u350064373 | 1501147387 | Python | Python3 | py | Runtime Error | 0 | 0 | 184 | import statistics
while True:
x = input()
if x == 0:
break
else:
ls = list(map(int, input().split()))
print("{0:.8f}".format(statistics.pstdev(ls))) |
s945842299 | p02381 | u498511622 | 1501147952 | Python | Python3 | py | Runtime Error | 0 | 0 | 164 | import statistics
while True:
s=int(input())
if s==0:
break
else:
lst=list(map(int,input().split()))
print("{0.8}".format(statitics.pstdev(lst)))
|
s004290736 | p02381 | u498511622 | 1501147992 | Python | Python3 | py | Runtime Error | 0 | 0 | 165 | import statistics
while True:
s=int(input())
if s==0:
break
else:
lst=list(map(int,input().split()))
print("{0:.8}".format(statitics.pstdev(lst)))
|
s439102780 | p02381 | u311299757 | 1501388382 | Python | Python3 | py | Runtime Error | 0 | 0 | 142 | from statistics import pstdev
while True:
if input() == 0: break
v_list = (int(x) for x in input().split())
print(pstdev(v_list)) |
s006408252 | p02381 | u666221014 | 1505125492 | Python | Python3 | py | Runtime Error | 0 | 0 | 157 | import numpy as np
while True:
num = int(input())
if num == 0: break
array = np.array(list(map(float, input().split())))
print(np.std(array)) |
s987280857 | p02381 | u666221014 | 1505125575 | Python | Python3 | py | Runtime Error | 0 | 0 | 162 | import numpy as np
while True:
num = int(input())
if num == 0: break
array = np.array(list(map(float, input().split())))
print(str(np.std(array))) |
s469743079 | p02381 | u933096856 | 1505444607 | Python | Python3 | py | Runtime Error | 0 | 0 | 130 | import bumpy as np
while True:
n= int(input())
if n == 0:
break
a=map(int, input().split())
print(np.std(a) |
s668151733 | p02381 | u933096856 | 1505444628 | Python | Python3 | py | Runtime Error | 0 | 0 | 130 | import numpy as np
while True:
n= int(input())
if n == 0:
break
a=map(int, input().split())
print(np.std(a) |
s655203615 | p02381 | u933096856 | 1505444644 | Python | Python3 | py | Runtime Error | 0 | 0 | 131 | import numpy as np
while True:
n= int(input())
if n == 0:
break
a=map(int, input().split())
print(np.std(a)) |
s809981831 | p02381 | u933096856 | 1505444661 | Python | Python3 | py | Runtime Error | 0 | 0 | 132 | import numpy as np
while True:
n= int(input())
if n == 0:
break
a=map(int, input().split())
print(np.std(a)) |
s803660929 | p02381 | u933096856 | 1505445001 | Python | Python3 | py | Runtime Error | 0 | 0 | 130 | import numpy as np
while True:
n= int(input())
if n == 0:
break
print(np.std(list(map(int, input().split())))) |
s001455621 | p02381 | u933096856 | 1505445110 | Python | Python3 | py | Runtime Error | 0 | 0 | 148 | import numpy as np
while True:
n= int(input())
if n == 0:
break
print(np.std(list(map(int, input().split())), dtype=np.float64)) |
s483609979 | p02381 | u933096856 | 1505445162 | Python | Python3 | py | Runtime Error | 0 | 0 | 148 | import numpy as np
while True:
n= int(input())
if n == 0:
break
print(np.std(list(map(int, input().split())), dtype=np.float64)) |
s958078037 | p02381 | u933096856 | 1505445574 | Python | Python3 | py | Runtime Error | 0 | 0 | 223 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(int,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print(math.sqrt(s)) |
s163322376 | p02381 | u933096856 | 1505445727 | Python | Python3 | py | Runtime Error | 0 | 0 | 240 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(int,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s440112183 | p02381 | u933096856 | 1505445777 | Python | Python3 | py | Runtime Error | 0 | 0 | 241 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
quit()
a=list(map(int,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s187120309 | p02381 | u933096856 | 1505479115 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(float,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s564416269 | p02381 | u933096856 | 1505479136 | Python | Python3 | py | Runtime Error | 0 | 0 | 241 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(float,input().split())
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s449278068 | p02381 | u933096856 | 1505479143 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(float,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s048230974 | p02381 | u933096856 | 1505479236 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | import numpy as np
import math
while True:
n= int(input())
if n == 0:
break
a=list(map(float,input().split()))
m=np.mean(a)
s=0
for i in a:
s+=(i-m)**2
s/=n
print("{0:.8f}".format(math.sqrt(s))) |
s700134844 | p02381 | u518939641 | 1510404163 | Python | Python3 | py | Runtime Error | 0 | 0 | 109 | import numpy as np
while input()!='0':
print('%.8f'%(np.std(np.array(list(map(float,input().split())))))) |
s478736238 | p02381 | u406002631 | 1514029527 | Python | Python3 | py | Runtime Error | 0 | 0 | 201 | import numpy as np
while True:
n = int(input())
if n == 0:
break
s = list(map(int, input().split()))
for i in range(n):
std = np.std(s)
print("{0:.8f}".format(std)) |
s802890302 | p02381 | u406002631 | 1514029640 | Python | Python3 | py | Runtime Error | 0 | 0 | 201 | import numpy as np
while True:
n = int(input())
if n == 0:
break
s = list(map(int, input().split()))
for i in range(n):
std = np.std(s)
print("{0:.8f}".format(std)) |
s358770919 | p02381 | u406002631 | 1514029810 | Python | Python3 | py | Runtime Error | 0 | 0 | 216 | import numpy as np
while True:
n = int(input())
if n == 0:
break
s = list(map(int, input().split()))
for i in range(n):
std = np.std(s)
print("{0:.8f}".format(std), end="\n")
|
s120101893 | p02381 | u406002631 | 1514029974 | Python | Python3 | py | Runtime Error | 0 | 0 | 206 | import numpy as np
while True:
n = int(input())
if n == 0:
break
s = list(map(int, input().split()))
for i in range(n):
std = np.std(s)
print("{0:.8f}".format(std))
|
s197979549 | p02381 | u426534722 | 1515943552 | Python | Python3 | py | Runtime Error | 0 | 0 | 166 | from statistics import pstdev
while True:
data_count = int(input())
if data_count == 0:
break
print(pstdev(sum(int(x) for x in input().split())))
|
s582128064 | p02381 | u017523606 | 1516165857 | Python | Python3 | py | Runtime Error | 0 | 0 | 227 | n = int(input())
data = input().split()
import math
sum = 0
for i in range(n):
sum = sum + int(data[I])
average = sum / n
a = 0
for i in range(n):
a = a + (int(data[i]) - average)**2
print('{}'.format(math.sqrt(a/n)))
|
s131512065 | p02381 | u017523606 | 1516166079 | Python | Python3 | py | Runtime Error | 0 | 0 | 303 | while True:
n = int(input())
if n == 0:
break
data = input().split()
import math
sum = 0
for i in range(n):
sum = sum + int(data[i])
average = sum / n
a = 0
for i in range(n):
a = a + (int(data[i]) - average)**2
print('{}'.format(math.sqrt(a/n)))
|
s472749767 | p02381 | u150984829 | 1516366691 | Python | Python3 | py | Runtime Error | 0 | 0 | 113 | while input():
s=list(map(int,input().split()))
n=len(s)
a=sum(s)/n
print((sum([x*x for x in s])/n-a*a)**.5)
|
s323265814 | p02381 | u150984829 | 1516366811 | Python | Python3 | py | Runtime Error | 0 | 0 | 115 | while input()>0:
s=list(map(int,input().split()))
n=len(s)
a=sum(s)/n
print((sum([x*x for x in s])/n-a*a)**.5)
|
s157477294 | p02381 | u536089081 | 1517532013 | Python | Python3 | py | Runtime Error | 0 | 0 | 162 | import numpy as np
while True:
num = int(input())
if num == 0:
break
data = np.array(list(map(int, input().split())))
print(np.std(data))
|
s971096633 | p02381 | u613534067 | 1520344061 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | import math
while(True):
if input() == '0':
break
a = map(int, input().split())
m = sum(a) / len(a)
b = 0
for i in a:
b += (i - m) ** 2.0
stddev = math.sqrt(b / n)
print(stddev)
|
s875347633 | p02381 | u613534067 | 1520344076 | Python | Python3 | py | Runtime Error | 0 | 0 | 228 | import math
while(True):
if input() == '0':
break
a = list(map(int, input().split()))
m = sum(a) / len(a)
b = 0
for i in a:
b += (i - m) ** 2.0
stddev = math.sqrt(b / n)
print(stddev)
|
s901697160 | p02381 | u682153677 | 1524375510 | Python | Python3 | py | Runtime Error | 0 | 0 | 180 | # -*- coding: utf-8 -*-
from statistics import stdev
while True:
n = int(input())
if n == 0:
break
s = list(map(int, input().split()))
print(stdev(s))
|
s289178962 | p02381 | u682153677 | 1524376126 | Python | Python3 | py | Runtime Error | 0 | 0 | 325 | # -*- coding: utf-8 -*-
import math
while True:
n = int(input())
if n == 0:
break
s = list(map(float, input().split()))
mean = sum(s) / len(s)
for i in range(len(s)):
s[i] = (s[i] - sum) * (s[i] - sum)
variance = sum(s) / len(s)
stdev = math.sqrt(variance)
print(stdev)
|
s969165680 | p02381 | u603663339 | 1524736195 | Python | Python3 | py | Runtime Error | 0 | 0 | 165 | import numpy as np
while 1:
N = int(input())
if N == 0:
break
xs = np.array(list(map(int, input().split())))
print(np.sqrt(np.var(xs)))
|
s603964161 | p02381 | u603663339 | 1524736247 | Python | Python3 | py | Runtime Error | 0 | 0 | 165 | import numpy as np
while 1:
N = int(input())
if N == 0:
break
xs = np.array(list(map(int, input().split())))
print(np.sqrt(np.var(xs)))
|
s519647506 | p02381 | u603663339 | 1524736320 | Python | Python3 | py | Runtime Error | 0 | 0 | 165 | import numpy as np
while 1:
N = int(input())
if N == 0:
break
xs = np.array(list(map(int, input().split())))
print(np.sqrt(np.var(xs)))
|
s179818557 | p02381 | u603663339 | 1524737116 | Python | Python3 | py | Runtime Error | 0 | 0 | 175 | import numpy as np
while 1:
N = int(input())
if N == 0:
break
xs = np.array(list(map(int, input().split())))
print(xs)
print(np.sqrt(np.var(xs)))
|
s074912798 | p02381 | u603663339 | 1524737602 | Python | Python3 | py | Runtime Error | 0 | 0 | 71 | while 1:
N = int(input())
if N == 0:
break
print(0)
|
s541716110 | p02381 | u843169619 | 1525905162 | Python | Python3 | py | Runtime Error | 0 | 0 | 178 | import statistics as st
while True:
n = float(input())
if n == 0:
break
scores = list(map(float, input().split()))
std = st.stdev(scores)
print(std)
|
s686212816 | p02381 | u986478725 | 1527350668 | Python | Python3 | py | Runtime Error | 0 | 0 | 504 | # AOJ ITP1_10_C
import math
def intinput():
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
return a
def main():
while True:
n = int(input())
if n == 0: break
data = intinput()
sum_1 = 0 # 1乗の総和
sum_2 = 0 # 2乗の総和
for i in range(n):
sum_1 += data[i]; sum_2 += data[i] ** 2
sigma = math.sqrt((sum_2 - (sum_1 ** 2)) / n)
print(sigma)
if __name__ == "__main__":
main()
|
s156580448 | p02381 | u912237403 | 1371253842 | Python | Python | py | Runtime Error | 0 | 0 | 210 | while True:
n = int(raw_input())
if n == 0: break
for i in range(n):
x = map(int, raw_input().split())
ave = sum(x) / n
std = (sum([(e-ave)**2 for e in x])/n)**0.5
print std |
s514115339 | p02381 | u140201022 | 1382374978 | Python | Python | py | Runtime Error | 0 | 0 | 394 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math
while True:
# i = 0
n = int(raw_input())
l = map(float, raw_input().split())
if n==0: break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
avg=sum(l)/len(l)
print avg
naka=0
for i in l:
print naka
naka+=(i-avg)**2
hyo2 = naka/n
print (hyo2)**0.5 |
s136689750 | p02381 | u140201022 | 1382375060 | Python | Python | py | Runtime Error | 0 | 0 | 387 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math
while True:
n = int(raw_input())
l = map(float, raw_input().split())
if n==0:
break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
avg=sum(l)/len(l)
print avg
naka=0
for i in l:
print naka
naka+=(i-avg)**2
hyo2 = naka/n
print (hyo2)**0.5 |
s649280901 | p02381 | u140201022 | 1382375220 | Python | Python | py | Runtime Error | 0 | 0 | 361 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import io
import re
import math
while True:
# i = 0
n = int(raw_input())
l = map(float, raw_input().split())
if n==0: break
# hyojunhensa**2 = sum(tokuten-heikinten)**2)/ninzu
avg=sum(l)/len(l)
naka=0
for i in l:
naka+=(i-avg)**2
hyo2 = naka/n
print (hyo2)**0.5 |
s021235682 | p02382 | u435313013 | 1559180177 | Python | Python3 | py | Runtime Error | 0 | 0 | 551 | import math
class Triangle(object):
def __init__(self, a, b, C):
self.a = a
self.b = b
self.C = math.radians(C)
def getArea(self):
return((self.a * self.getHeight()) / 2)
def getPerimeter(self):
return(self.a + self.b + math.sqrt(self.a ** 2 + self.b ** 2 - 2 * self.a * self.b * math.cos(self.C)))
def getHeight(self):
return(self.b * math.sin(self.C))
tri = Triangle(*[int(i) for i in input().split()])
print(tri.getArea())
print(tri.getPerimeter())
print(tri.getHeight())
|
s178660829 | p02382 | u297342993 | 1423702343 | Python | Python3 | py | Runtime Error | 0 | 0 | 325 | import math
input()
vx = [int(i) for i in input().split()]
vy = [int(i) for i in input().split()]
Dxy = []
for p in range(1, 4):
Dxy.append(sum([abs(xv[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p))
Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))
for res in Dxy:
print('{0:5f}'.format(res)) |
s384706246 | p02382 | u811841526 | 1449090921 | Python | Python3 | py | Runtime Error | 0 | 0 | 419 | def manhattan(xs, ys):
d = sum([abs(x-y) for x, y in zip(xs, ys)])
return d
def euclid(xs, ys):
return math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)]))
def chev(xs, ys):
return max([abs(x-y) for x, y in zip(xs, ys)])
def norm():
n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(manhattan(xs, ys), euclid(xs, ys), chev(xs, ys))
norm() |
s306800642 | p02382 | u811841526 | 1449090996 | Python | Python3 | py | Runtime Error | 0 | 0 | 419 | def manhattan(xs, ys):
d = sum([abs(x-y) for x, y in zip(xs, ys)])
return d
def euclid(xs, ys):
return math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)]))
def chev(xs, ys):
return max([abs(x-y) for x, y in zip(xs, ys)])
def norm():
n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(manhattan(xs, ys), euclid(xs, ys), chev(xs, ys))
norm() |
s197007549 | p02382 | u811841526 | 1449091187 | Python | Python3 | py | Runtime Error | 0 | 0 | 528 | def manhattan(xs, ys):
return sum([abs(x-y) for x, y in zip(xs, ys)])
def euclid(xs, ys):
return math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)]))
def l3(xs, ys):
return (sum([(x-y)*** for x, y in zip(xs, ys)]))**(1/3)
def chev(xs, ys):
return max([abs(x-y) for x, y in zip(xs, ys)])
def norm():
n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(manhattan(xs, ys))
print(euclid(xs, ys))
print(l3(xs, ys))
print(chev(xs, ys))
norm() |
s669624711 | p02382 | u811841526 | 1449091254 | Python | Python3 | py | Runtime Error | 0 | 0 | 211 | n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(manhattan(xs, ys))
print(euclid(xs, ys))
print(l3(xs, ys))
print(chev(xs, ys))
norm() |
s876707525 | p02382 | u811841526 | 1449091270 | Python | Python3 | py | Runtime Error | 0 | 0 | 183 | n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(manhattan(xs, ys))
print(euclid(xs, ys))
print(l3(xs, ys))
print(chev(xs, ys))
norm() |
s560723960 | p02382 | u811841526 | 1449091294 | Python | Python3 | py | Runtime Error | 0 | 0 | 98 | n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
norm() |
s451124738 | p02382 | u811841526 | 1449091350 | Python | Python3 | py | Runtime Error | 0 | 0 | 299 | n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(sum([abs(x-y) for x, y in zip(xs, ys)]))
print(math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)])))
print((sum([(x-y)*** for x, y in zip(xs, ys)]))**(1/3))
print(max([abs(x-y) for x, y in zip(xs, ys)])) |
s564804370 | p02382 | u811841526 | 1449091390 | Python | Python3 | py | Runtime Error | 0 | 0 | 299 | n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
print(sum([abs(x-y) for x, y in zip(xs, ys)]))
print(math.sqrt(sum([(x-y)**2 for x, y in zip(xs, ys)])))
print((sum([(x-y)**3 for x, y in zip(xs, ys)]))**(1/3))
print(max([abs(x-y) for x, y in zip(xs, ys)])) |
s250332653 | p02382 | u396164240 | 1449716934 | Python | Python | py | Runtime Error | 0 | 0 | 601 | inf = float('inf')
def distance(p,n,x,y):
D = 0.0
s = []
for i in range(0,n):
s.append(x[i]-y[i])
if s[i]<0.0:
s[i]*=-1.0
D += s[i]**p
if p==inf:
return max(s)
else:
return D**(1.0/p)
if __name__ == '__main__':
n = int(input())
x = []
y = []
for i in range(0,n):
x.append(int(input()))
for i in range(0,n):
y.append(int(input()))
print float(distance(1,n,x,y))
print float(distance(2,n,x,y))
print float(distance(3,n,x,y))
print float(distance(inf,n,x,y)) |
s435987860 | p02382 | u396164240 | 1449717022 | Python | Python | py | Runtime Error | 0 | 0 | 685 | # -*- coding: utf-8 -*-
"""
Created on Thu Dec 10 11:31:39 2015
@author: Ryuhei
"""
inf = float('inf')
def distance(p,n,x,y):
D = 0
s = []
for i in range(0,n):
s.append(x[i]-y[i])
if s[i]<0.0:
s[i]*=-1.0
D += s[i]**p
if p==inf:
return max(s)
else:
return D**(1.0/p)
if __name__ == '__main__':
n = int(input())
x = []
y = []
for i in range(0,n):
x.append(int(input()))
for i in range(0,n):
y.append(int(input()))
print float(distance(1,n,x,y))
print float(distance(2,n,x,y))
print float(distance(3,n,x,y))
print float(distance(inf,n,x,y)) |
s485425563 | p02382 | u670498238 | 1463700129 | Python | Python3 | py | Runtime Error | 0 | 0 | 317 | import math
n = int(input)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for p in range(1, 4):
D = []
for count in range(n):
D.append((math.fabs(A[count] - B[count]))** p)
if p == 1:
di = max(D)
d = (sum(D)) ** (1/p)
print('%.06f' %d)
print('%.06f' % di) |
s693137962 | p02382 | u216425054 | 1471445206 | Python | Python3 | py | Runtime Error | 0 | 0 | 275 | n=int(input())
vector1=[int(x) for x in input().split()]
vector2=[int(x) for x in input().split()]
for i in range(1,4):
print("{0:.8f}".format(sum([abs(a-b)**p for a,b in zip(vector1,vector2)])**(1/p)))
print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)]))) |
s330131002 | p02382 | u216425054 | 1471445244 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | n=int(input())
vector1=[int(x) for x in input().split()]
vector2=[int(x) for x in input().split()]
for i in range(1,4):
print("{0:.8f}".format(sum([abs(a-b)**p for a,b in zip(vector1,vector2)])**(1/p)))
print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)]))) |
s015857628 | p02382 | u216425054 | 1471445289 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | n=int(input())
vector1=[int(x) for x in input().split()]
vector2=[int(x) for x in input().split()]
for i in range(1,4):
print("{0:.8f}".format(sum([abs(a-b)**p for a,b in zip(vector1,vector2)])**(1/i)))
print("{0:.8f}".format(max([abs(a-b) for a,b in zip(vector1,vector2)]))) |
s548326748 | p02382 | u998435601 | 1473608502 | Python | Python3 | py | Runtime Error | 0 | 0 | 288 | import math
n = int(input())
x = list(map(int, raw_input().split()))
y = list(map(int, raw_input().split()))
t1 = t2 = t3 = ti = 0.0
for a, b in zip(x, y):
d1 = abs(a - b)
ti = max(ti, d1)
t1 += d1
t2 += d1**2
t3 += d1**3
print(t1)
print(math.sqrt(t2))
print(t3 ** (1.0/3))
print(ti) |
s174215143 | p02382 | u391228754 | 1476167679 | Python | Python3 | py | Runtime Error | 30 | 7808 | 415 | import math
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
p1, p2, p3, p4 = 0, 0, 0, 0
hyp = 0
for i in range(n):
p1 += math.fabs(a1[i] -a2[i])
p2 += (a1[i]-a2[i])**2
p3 += math.fabs((a1[i]-a2[i])**3)
hyp = math.fabs(a1[i] -a2[i])
if hyp > p4:
p4 = hyp
p2 = math.sqrt(p2)
p3 = math.exp(math.log(p3)/3)
print(p1)
print(p2)
print(p3)
print(p4) |
s544656945 | p02382 | u175111751 | 1477795955 | Python | Python3 | py | Runtime Error | 0 | 0 | 270 | import math
n = int(input())
x, y = [list(map(int, input().split())) for _ in range(2)]
for p in (1,2,3,math.inf):
if p == math.inf:
print(max(abs(x-y) for x, y in zip(x,y)))
else:
print(math.pow(sum(abs(x-y) ** p for x, y in zip(x,y)), 1.0 / p)) |
s929241306 | p02382 | u801346721 | 1479048099 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for p in range(1, 4):
sum = 0
for i in range(n):
sum += math.fabs(x[i]-y[i])**p
print(sum**(1/p))
sum = 0
for i in range(n):
sum += math.fabs(x[[i]-y[i])**math.inf
print(sum**(1/math.inf)) |
s395759136 | p02382 | u801346721 | 1479048602 | Python | Python3 | py | Runtime Error | 0 | 0 | 288 | import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for p in range(1, 4):
sum = 0
for i in range(n):
sum += math.fabs(x[i]-y[i])**p
print(sum**(1/p))
a = []
for i in range(n):
a.append(math.fabs(x[i]-y[i]))
a = a.sort()
print(a[n]) |
s639354067 | p02382 | u801346721 | 1479048630 | Python | Python3 | py | Runtime Error | 0 | 0 | 290 | import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for p in range(1, 4):
sum = 0
for i in range(n):
sum += math.fabs(x[i]-y[i])**p
print(sum**(1/p))
a = []
for i in range(n):
a.append(math.fabs(x[i]-y[i]))
a = a.sort()
print(a[n-1]) |
s127059877 | p02382 | u811733736 | 1480640993 | Python | Python3 | py | Runtime Error | 0 | 0 | 988 | import math
def calc_minkowski_distance(data_x, data_y, types):
# ???????´???????????¨???????map???????????¬??????????????????????????¨????????¨????????§?¶???????????????????????????§????????????????????????
distance = list(map(lambda x, y:abs(x - y), data_x, data_y))
results = []
for t in types:
if t == math.inf:
results.append(max(distance))
else:
temp = map(lambda x:math.pow(x, t), distance)
total = sum(temp)
results.append(math.pow(total, 1.0/t))
return results
if __name__ == '__main__':
# ??????????????\???
# data_x = [1, 2, 3]
# data_y = [2, 0, 4]
num = int(input())
data_x = [int(x) for x in input().split(' ')]
data_y = [int(x) for x in input().split(' ')]
# ???????????????
types = [1, 2, 3, math.inf]
results = calc_minkowski_distance(data_x, data_y, types)
# ???????????¨???
for r in results:
print('{0:.6f}'.format(r)) |
s290712383 | p02382 | u811733736 | 1480641077 | Python | Python3 | py | Runtime Error | 0 | 0 | 988 | import math
def calc_minkowski_distance(data_x, data_y, types):
# ???????´???????????¨???????map???????????¬??????????????????????????¨????????¨????????§?¶???????????????????????????§????????????????????????
distance = list(map(lambda x, y:abs(x - y), data_x, data_y))
results = []
for t in types:
if t == math.inf:
results.append(max(distance))
else:
temp = map(lambda x:math.pow(x, t), distance)
total = sum(temp)
results.append(math.pow(total, 1.0/t))
return results
if __name__ == '__main__':
# ??????????????\???
# data_x = [1, 2, 3]
# data_y = [2, 0, 4]
num = int(input())
data_x = [int(x) for x in input().split(' ')]
data_y = [int(x) for x in input().split(' ')]
# ???????????????
types = [1, 2, 3, math.inf]
results = calc_minkowski_distance(data_x, data_y, types)
# ???????????¨???
for r in results:
print('{0:.8f}'.format(r)) |
s365821387 | p02382 | u042885182 | 1493906967 | Python | Python3 | py | Runtime Error | 0 | 0 | 2550 | # coding: utf-8
# Here your code !
import sys
import collections
import math
import unittest
def calculate_minkowski_distances():
lines = sys.stdin.readlines()[1:]
data = []
for line in lines:
data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, math.inf):
print(minkowski_distance(*data, exponent))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
#test
if __name__ == "__main__" :
test = __TestValueClass()
vec_x = [1, 2, 3]
vec_y = [2, 0, 4]
test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s501237017 | p02382 | u042885182 | 1493907123 | Python | Python3 | py | Runtime Error | 0 | 0 | 2552 | # coding: utf-8
# Here your code !
import sys
import collections
import math
import unittest
def calculate_minkowski_distances():
lines = sys.stdin.readlines()[1:]
data = []
for line in lines:
data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, math.inf):
print(minkowski_distance(*data, exponent))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
#test
if __name__ == "__main__" :
test = __TestValueClass()
vec_x = [1, 2, 3]
vec_y = [2, 0, 4]
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s317361699 | p02382 | u042885182 | 1493907176 | Python | Python3 | py | Runtime Error | 0 | 0 | 777 | # coding: utf-8
# Here your code !
import sys
import math
def calculate_minkowski_distances():
lines = sys.stdin.readlines()[1:]
data = []
for line in lines:
data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, math.inf):
print(minkowski_distance(*data, exponent))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
#test
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s516416776 | p02382 | u042885182 | 1493907436 | Python | Python3 | py | Runtime Error | 0 | 0 | 2678 | # coding: utf-8
# Here your code !
import sys
import collections
import math
import unittest
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
# lines = sys.stdin.readlines()[1:]
# for line in lines:
# data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, math.inf):
print(minkowski_distance(*data, exponent))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
'''
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
# test = __TestValueClass()
# vec_x = [1, 2, 3]
# vec_y = [2, 0, 4]
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s160387027 | p02382 | u042885182 | 1493907493 | Python | Python3 | py | Runtime Error | 0 | 0 | 738 | # coding: utf-8
# Here your code !
import math
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, math.inf):
print(minkowski_distance(*data, exponent))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s110260565 | p02382 | u042885182 | 1493907618 | Python | Python3 | py | Runtime Error | 0 | 0 | 2696 | # coding: utf-8
# Here your code !
import sys
import collections
import math
import unittest
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
# lines = sys.stdin.readlines()[1:]
# for line in lines:
# data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, math.inf):
print("{0:.6f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
'''
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
# test = __TestValueClass()
# vec_x = [1, 2, 3]
# vec_y = [2, 0, 4]
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s075055740 | p02382 | u042885182 | 1493907682 | Python | Python3 | py | Runtime Error | 0 | 0 | 765 | # coding: utf-8
# Here your code !
import math
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, math.inf):
print("{0:.6f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if math.isinf(exponent) :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
#test
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s093112675 | p02382 | u042885182 | 1493907745 | Python | Python3 | py | Runtime Error | 0 | 0 | 2704 | # coding: utf-8
# Here your code !
import sys
import collections
#import math
import unittest
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
# lines = sys.stdin.readlines()[1:]
# for line in lines:
# data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, float("inf")):
print("{0:.6f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
'''
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
# test = __TestValueClass()
# vec_x = [1, 2, 3]
# vec_y = [2, 0, 4]
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s631139524 | p02382 | u042885182 | 1493907797 | Python | Python3 | py | Runtime Error | 0 | 0 | 751 | # coding: utf-8
# Here your code !
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, float("inf")):
print("{0:.6f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s823732413 | p02382 | u042885182 | 1493907995 | Python | Python3 | py | Runtime Error | 0 | 0 | 2704 | # coding: utf-8
# Here your code !
import sys
import collections
#import math
import unittest
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
# lines = sys.stdin.readlines()[1:]
# for line in lines:
# data.append([ float(value) for value in line.rstrip().split() ])
for exponent in (1, 2, 3, float("inf")):
print("{0:.8f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
'''
def __input_error():
print("input error")
return -1
class __TestValueClass(unittest.TestCase):
def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
#tuples[index] = ([*arguments of func], compared value)
for item in tuples:
try:
if isinstance(item[0], collections.Iterable):
value = func(*item[0])
else:
value = func(item[0])
if math.isnan(eff_digit) :
assertfunc(value,item[1])
else :
format_str = "{0:."+str(eff_digit)+"g}"
assertfunc(format_str.format(value),format_str.format(item[1]))
except Exception as msg:
swidth = 15
print("="*50)
print("-- Assertion Error in '" + func.__name__ + "' --")
print("arguments".ljust(swidth)+":",item[0])
print("compared value".ljust(swidth)+":",item[1])
print("message".ljust(swidth)+":")
print(msg)
sys.exit()
if print_success :
print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
# test = __TestValueClass()
# vec_x = [1, 2, 3]
# vec_y = [2, 0, 4]
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 1], 4), ([vec_x, vec_y, 2], 2.449490)], eff_digit = 5)
# test.testEqual(minkowski_distance, [([vec_x, vec_y, 3], 2.154435), ([vec_x, vec_y, math.inf], 2)], eff_digit = 5)#, print_success = True)
calculate_minkowski_distances()
|
s073944273 | p02382 | u042885182 | 1493908052 | Python | Python3 | py | Runtime Error | 0 | 0 | 752 | # coding: utf-8
# Here your code !
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, float("inf")):
print("{0:.8f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s377524951 | p02382 | u042885182 | 1493908155 | Python | Python3 | py | Runtime Error | 0 | 0 | 833 | # coding: utf-8
# Here your code !
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, float("inf")):
print("{0:.8f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
# abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
abs_xy = [abs(vector_x[i] - vector_y[i]) for i in range(len(vector_x))]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s250254614 | p02382 | u042885182 | 1493908641 | Python | Python3 | py | Runtime Error | 0 | 0 | 885 | # coding: utf-8
# Here your code !
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([float(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, float("inf")):
print(minkowski_distance(*data, exponent))
# print("{0:.8f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
# abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
abs_xy = [abs(vector_x[i] - vector_y[i]) for i in range(len(vector_x))]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = ( sum([ elem**exponent for elem in abs_xy ])**(1/exponent) )
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s498195797 | p02382 | u042885182 | 1493908817 | Python | Python3 | py | Runtime Error | 0 | 0 | 879 | # coding: utf-8
# Here your code !
def calculate_minkowski_distances():
_ = input()
data = []
for i in range(2):
data.append([int(value) for value in input().rstrip().split()])
for exponent in (1, 2, 3, float("inf")):
print(minkowski_distance(*data, exponent))
# print("{0:.8f}".format(minkowski_distance(*data, exponent)))
def minkowski_distance(vector_x, vector_y, exponent):
# abs_xy = [ abs(pair[0] - pair[1]) for pair in zip(vector_x, vector_y) ]
abs_xy = [abs(vector_x[i] - vector_y[i]) for i in range(len(vector_x))]
m_dis = 0
if exponent == float("inf") :
m_dis = max(abs_xy)
elif exponent == 0 :
m_dis = nan
else :
m_dis = sum([ elem**exponent for elem in abs_xy ])**(1/exponent)
return m_dis
if __name__ == "__main__" :
calculate_minkowski_distances()
|
s480162518 | p02382 | u623167544 | 1494385218 | Python | Python3 | py | Runtime Error | 20 | 7664 | 488 |
def dis_func(n, x, y):
dis = [round(0, 6) for i in range(n+1)]
for x, y in zip(x, y):
tmp = abs(x - y)
dis[0] += tmp
dis[1] += (tmp ** 2)
dis[2] += (tmp ** 3)
dis[3] = max(dis[3], tmp)
dis[1] = dis[1] ** (1/2)
dis[2] = dis[2] ** (1/3)
print('\n'.join(list(map(str, dis))))
if __name__ == '__main__':
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
dis_func(n, x, y) |
s077852593 | p02382 | u213265973 | 1494484011 | Python | Python3 | py | Runtime Error | 0 | 0 | 307 | n = int(input())
X = [int(i) for i in input().split(" ")]
Y = [int(i) for i in input().split(" ")]
#p = 1,2,3
for p in range(1, 4):
print("{:.6f}".format(sum( [abs(a - b) ** p) for a, b in zip(X,Y) ] ) ** (1 / p) ) )
#p = infinity
print("{:.6f}".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )
|
s508480958 | p02382 | u213265973 | 1494484024 | Python | Python3 | py | Runtime Error | 0 | 0 | 282 | n = int(input())
X = [int(i) for i in input().split(" ")]
Y = [int(i) for i in input().split(" ")]
for p in range(1, 4):
print("{:.6f}".format(sum( [abs(a - b) ** p) for a, b in zip(X,Y) ] ) ** (1 / p) ) )
print("{:.6f}".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )
|
s830928063 | p02382 | u213265973 | 1494484085 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | n = int(input())
X = [int(i) for i in input().split(" ")]
Y = [int(i) for i in input().split(" ")]
for p in range(1, 4):
print("{:.6f}".format(sum( [abs(a - b) ** p) for a, b in zip(X,Y) ] ) ** (1 / p) ) )
print("{:.6f}".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.