Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Distance II

  Your task is to calculate the distance between two $n$ dimensional vectors $x = \{x_1, x_2, ..., x_n\}$ and $y = \{y_1, y_2, ..., y_n\}$.

  The Minkowski's distance defined below is a metric which is a generalization of both the Manhattan distance and the Euclidean distance.

\[
D_{xy} = (\sum_{i=1}^n |x_i - y_i|^p)^{\frac{1}{p}}
\]

It can be the Manhattan distance 

\[
D_{xy} = |x_1 - y_1| + |x_2 - y_2| + ... + |x_n - y_n|
\]

where $p = 1 $.

It can be the Euclidean distance

\[
D_{xy} = \sqrt{(|x_1 - y_1|)^{2} + (|x_2 - y_2|)^{2} + ... + (|x_n - y_n|)^{2}}
\]

where $p = 2 $.

Also, it can be the Chebyshev distance

\[
D_{xy} = max_{i=1}^n (|x_i - y_i|)
\]

where $p = \infty$

Write a program which reads two $n$ dimensional vectors $x$ and $y$, and calculates Minkowski's distance where $p = 1, 2, 3, \infty$ respectively.

Input

  In the first line, an integer $n$ is given. In the second and third line, $x = \{x_1, x_2, ... x_n\}$ and $y = \{y_1, y_2, ... y_n\}$ are given respectively. The elements in $x$ and $y$ are given in integers.

Output

  Print the distance where $p = 1, 2, 3$ and $\infty$ in a line respectively.
The output should not contain an absolute error greater than 10-5.

Constraints

$1 \leq n \leq 100$

$0 \leq x_i, y_i \leq 1000$

Sample Input

3
1 2 3
2 0 4

Sample Output

4.000000
2.449490
2.154435
2.000000



Sample input:
3
1 2 3
2 0 4


Sample output:
4.000000
2.449490
2.154435
2.000000

Submission status: Wrong Answer

Solution code:
d = int(input())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

D_1 = 0
for i in range(d):
    L_i = abs(x[i] - y[i])
    D_1 += L_i

D_2 = 0
for i in range(d):
    L_i = (x[i]-y[i])**2
    D_2 += L_i
D_2 = (D_2) **(1/2)

D_3 = 0
for i in range(d):
    L_i = (x[i]-y[i])**3
    D_3 += L_i
D_3 = (D_3) ** (1/3)

L =[]
for i in range(d):
    L.append(abs(x[i]-y[i]))

D_ = max(L)

print(D_1)
print(D_2)
print(D_3)
print(D_)

Submission status: Wrong Answer

Solution code:
import decimal
d = int(input())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

D_1 = 0
for i in range(d):
    L_i = abs(x[i] - y[i])
    D_1 += L_i

D_2 = 0
for i in range(d):
    L_i = (x[i]-y[i])**2
    D_2 += L_i
D_2 = (D_2) **(1/2)

D_3 = 0
for i in range(d):
    L_i = (x[i]-y[i])**3
    D_3 += L_i
D_3 = (D_3) ** (1/3)

L =[]
for i in range(d):
    L.append(abs(x[i]-y[i]))

D_ = max(L)

print('{:.8f}'.format(D_1))
print('{:.8f}'.format(D_2))
print('{:.8f}'.format(D_3))
print('{:.8f}'.format(D_))

Submission status: Wrong Answer

Solution code:
n=int(input())
s_str=[]
for i in range(2):
    s_str.append(input().split())
s_int=[]
for i in s_str:
    s_int.append([int(s) for s in i])
manh=0
yu=0
p_3=0
che=[]
for i in range(n):
    manh+=abs(s_int[0][i]-s_int[1][i])
    yu+=(s_int[0][i]-s_int[1][i])**2
    p_3+=(s_int[0][i]-s_int[1][i])**3
    che.append(abs(s_int[0][i]-s_int[1][i]))
print(manh)
print(yu**(1/2))
print(p_3**(1/3))
print(max(che))

Submission status: Wrong Answer

Solution code:
num = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
first = second = third = inf = 0.00000
for i in range(num):
    dif = x[i] - y[i]
    first = first + abs(dif)
    second = second + dif ** 2
    third = third + abs(dif) ** 3
    inf = max(inf, abs(dif))
print(float(first))
print(float(second ** 0.5))
print(float(third ** 0.3333))
print(float(inf))

Submission status: Wrong Answer

Solution code:
num = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
first = second = third = inf = 0.00000
for i in range(num):
    dif = x[i] - y[i]
    first = first + abs(dif)
    second = second + dif ** 2
    third = third + abs(dif) ** 3
    inf = max(inf, abs(dif))
print('{:.5f}'.format(first))
print('{:.5f}'.format(second ** 0.5))
print('{:.5f}'.format(third ** 0.3333))
print('{:.5f}'.format(inf))

Submission status: Wrong Answer

Solution code:
num = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
first = second = third = inf = 0.00000
for i in range(num):
    dif = x[i] - y[i]
    first = first + abs(dif)
    second = second + dif ** 2
    third = third + abs(dif) ** 3
    inf = max(inf, abs(dif))
print('{:.6f}'.format(first))
print('{:.6f}'.format(second ** 0.5))
print('{:.6f}'.format(third ** 0.33333333))
print('{:.6f}'.format(inf))

Submission status: Wrong Answer

Solution code:
def dist(X, Y, p):
    sum(abs(x - y) ** p for x, y in zip(X,Y)) ** (1.0 / p)
    
n = input()
X = map(int, raw_input().split())
Y = map(int, raw_input().split())
for i in [1, 2, 3]:
    print dist(X, Y, i)
print max(map(lambda xy: abs(xy[0] - xy[1]), zip(X, Y)))

Submission status: Wrong Answer

Solution code:
n = int(input())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

Submission status: Wrong Answer

Solution code:
import math

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)**3 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()

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,100]


for p in pp:
	print(  sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  )

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,100]


for p in pp:
	print( "{0:f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,300]


for p in pp:
	print( "{0:f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,500]


for p in pp:
	print( "{0:f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,1000]


for p in pp:
	print( "{0:f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1,2,3,500]


for p in pp:
	print( "{0:2.8f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1.0, 2.0, 3.0, 500.0]


for p in pp:
	print( "{0:2.8f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1/p)  ))

Submission status: Wrong Answer

Solution code:
# 22-Math_Functions-Distance_II.py

# ??????????????????????????¢
# ???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
# ????????????????????°???????????????????§?????????¨????????§????????????????????????
# ????????§??????????????? n ?¬????????????????
#  x={x1,x2,...,xn} ??¨
#  y={y1,y2,...,yn} 
# ????????¢????¨????????????????????????????

# ????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\????????????????????? 
# Dxy=(???{i=1n}|xi???yi|^p)1/p

# p=1 ?????¨??? 
# Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

# ??¨?????????????????????????????????????????¢??¨?????°???????????? 

# p=2 ?????¨??? 
# Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????
# ??¨???????????????????????¬?????????????????????????????????????????¢?????????????????? 

# p=??? ?????¨??? 
# Dxy=maxni=1(|xi???yi|)
# ??¨???????????????????????§????????§????????¢??¨?????°????????????

# ????????? n ?¬???????????????????????????????????????§???
# p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

# Input
# ??????????????´??° n ????????????????????????
# ???????????????????????? x ???????´? {x1,x2,...xn}{x1,x2,...xn}???
# ???????????????????????? y ???????´? {y1,y2,...yn}{y1,y2,...yn} 
# ????????????????????§???????????????????????\?????????????????´??°?????§??????

# Output
# p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????
# ????????????0.00001 ??\????????????????????£????????????????????¨????????????

# Constraints
# 1???n???100
# 0???xi,yi???1000
# Sample Input
# 3
# 1 2 3
# 2 0 4
# Sample Output
# 4.000000
# 2.449490
# 2.154435
# 2.000000

n = int(input())
x = list( map(int, input().split()) )
y = list( map(int, input().split()) )
pp=[1.0, 2.0, 3.0, 500.0]


for p in pp:
	print( "{0:.8f}".format( sum( [abs(x[i]-y[i])**p for i in range(n)] )**(1./p)  ))

Submission status: Wrong Answer

Solution code:
n = input()
x = list(map(int,raw_input().split()))
y = list(map(int,raw_input().split()))
gap = []
gap1 = 0.0
gap2 = 0.0
gap3 = 0.0
a = 0.0

for i in range(n):
    gap.append(abs(x[i]-y[i]))

for i in range(n):
    gap1 += gap[i]
print gap1

for i in range(n):
    gap2 += gap[i] ** 2  

print pow(gap2,0.5)

for i in range(n):
    gap3 += gap[i] ** 3
print pow(gap3,0.3333333)

print max(gap)

Submission status: Wrong Answer

Solution code:
import math
p = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
sum = 0

for i in range(p):
 sum += math.fabs(x[i]-y[i])**p

print(sum**(1/p))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
def nor(x,y,p):
    sum = 0
    for i in range(len(x)):
        sum += (abs(x[i]-y[i]))**p
    return sum**(1/p)
        
n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))

print(nor(x,y,1))
print(nor(x,y,2))
print(nor(x,y,3))
print(nor(x,y,1000))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [X-Y for (X,Y) in zip(x, y)]

print(sum(z))

z2 = [Z ** 2 for Z in z]

print(math.sqrt(sum(z2)))
print(max(z))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import math

chebyshev = []

n = int(input())

x = input().split()
y = input().split()

for i in range(n):
    x[i] = int(x[i])
for i in range(n):
    y[i] = int(y[i])

for p in range(3):
    total = 0
    for i in range(n):
        total += (math.fabs(x[i]-y[i]))**(p+1)
    distance = total**(1/(p+1))
    print("%.5f" % distance)

for i in range(n):
    chebyshev.append(x[i]-y[i])
print("%.5f" % max(chebyshev))

Submission status: Wrong Answer

Solution code:
#ITP1_10-D Distance2
n = int(input())
x = [float(x) for x in input().split(" ")]
y = [float(x) for x in input().split(" ")]

d1=0.0
for i in range(n):
    d1 += abs(x[i]-y[i])
print(d1)

d2=0.0
for i in range(n):
    d2 += (x[i]-y[i])**2
print(d2**(1/2))

d3=0.0
for i in range(n):
    d3 += (x[i]-y[i])**3
print(d3**(1/3))

d_inf=0.0
for i in range(n):
    if abs(x[i]-y[i])>d_inf:
        d_inf = x[i]-y[i]
print(d_inf)

Submission status: Wrong Answer

Solution code:
#ITP1_10-D Distance2
n = int(input())
x = [float(x) for x in input().split(" ")]
y = [float(x) for x in input().split(" ")]

d1=0.0
for i in range(n):
    d1 += abs(x[i]-y[i])
print(d1)

d2=0.0
for i in range(n):
    d2 += (x[i]-y[i])**2
print(d2**(1/2))

d3=0.0
for i in range(n):
    d3 += abs((x[i]-y[i])**3)
print(d3**(1/3))

d_inf=0.0
for i in range(n):
    if abs(x[i]-y[i])>d_inf:
        d_inf = x[i]-y[i]
print(d_inf)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
tmp = [[0 for i in range(6)] for j in range(n+1)]
absDiff = abs(x[0]-y[0])
tmp[0][3] = tmp[0][0] = absDiff
tmp[0][4] = tmp[0][1] = absDiff ** 2
tmp[0][5] = tmp[0][2] = absDiff ** 3
max = 0
for i in range(1, n, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = absDiff
    tmp[i][1] = absDiff ** 2
    tmp[i][2] = absDiff ** 3
    tmp[i][3] = tmp[i-1][3] + tmp[i][0]
    tmp[i][4] = tmp[i-1][4] + tmp[i][1]
    tmp[i][5] = tmp[i-1][5] + tmp[i][2]
    if absDiff > max:
        max = absDiff
print(tmp[i][3])
print(math.sqrt(tmp[i][4]))
print(tmp[i][5] ** (1/3))
print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] + list(map(int, input().split()))
y = [0] + list(map(int, input().split()))
tmp = [[0 for i in range(3)] for j in range(n+1)]
max = 0
for i in range(1, n+1, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = tmp[i-1][0] + absDiff
    tmp[i][1] = tmp[i-1][1] + absDiff ** 2
    tmp[i][2] = tmp[i-1][2] + tmp[i][1] * absDiff
    if absDiff > max:
        max = absDiff
print(tmp[n][0])
print(tmp[n][1] ** (1/2))
print(tmp[n][2] ** (1/3))
print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] + list(map(int, input().split()))
y = [0] + list(map(int, input().split()))
tmp = [[0 for i in range(3)] for j in range(n+1)]
max = 0
for i in range(1, n+1, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] += tmp[i-1][0] + absDiff
    tmp[i][1] += tmp[i-1][1] + absDiff ** 2
    tmp[i][2] += tmp[i-1][2] + tmp[i][1] * absDiff
    if absDiff > max:
        max = absDiff
print(tmp[n][0])
print(tmp[n][1] ** (1/2))
print(tmp[n][2] ** (1/3))
print(max)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
xs = list(map(float, input().split()))
ys = list(map(float, input().split()))


def mink(p):
    return math.pow(sum([
        math.pow(math.fabs(xs[i] - ys[i]), p)
        for i in range(n)
    ]), 1/p)


def float_print(v):
    print('{:.5f}'.format(v))


float_print(mink(1))
float_print(mink(2))
float_print(mink(3))
float_print(mink(1000))

Submission status: Wrong Answer

Solution code:
a=int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))
d1=0
d2=0
d3=0
for i in range(a):
    d1+=abs(x[i]-y[i])
    d2+=(x[i]-y[i])**2
    d3+=abs((x[i]-y[i])**3)
d22=d2**0.5
d33=d3**(1/3)
print(d1)
print(d22)
print(d33)
print(max([x[i]-y[i] for i in range(a)]))

Submission status: Wrong Answer

Solution code:
import math                                                      
ni = int(input())                                                
xi = map(int, raw_input().split())                               
yi = map(int, raw_input().split())                               
                                                                 
p1 = []                                                          
p2 = []                                                          
p3 = []                                                          
for x, y in zip(xi, yi):                                         
    p1.append(abs(x - y))                                        
    p2.append(abs(x - y)**2)                                     
    p3.append(abs(x - y))                                        
                                                                 
print '%.6f' % reduce(lambda x, y: x + y, p1)                    
print '%.6f' % math.sqrt(reduce(lambda x, y: x + y, p2))         
print '%.6f' % max(p3)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = list(map(float, input().split()))
Y = list(map(float, input().split()))
p1 = 0
i = 0
while i < N :
    p1 = p1 + abs(X[i]-Y[i])
    i = i + 1
print(p1)
p2 = 0
i = 0
while i < N :
    p2 = p2 + (X[i]-Y[i])**2
    i = i + 1
print (math.sqrt(p2))
p3 = abs(X[0]-Y[0])
i = 0
while i < N-1 :
    if abs(X[i]-Y[i]) < abs(X[i+1]-Y[i+1]) :
        p3 = abs(X[i+1]-Y[i+1])
    i = i + 1
print(p3)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = list(map(float, input().split()))
Y = list(map(float, input().split()))
p1 = 0
i = 0
while i < N :
    p1 = p1 + abs(X[i]-Y[i])
    i = i + 1
print(p1)

p2 = 0
i = 0
while i < N :
    p2 = p2 + (X[i]-Y[i])**2
    i = i + 1
print (math.sqrt(p2))

p3 = 0
i = 0
while i < N :
    p3 = p3 + abs((X[i]-Y[i])**3)
    i = i + 1
print(math.pow(p3, (1/3)))

p4 = abs(X[0]-Y[0])
i = 0
while i < N-1 :
    if abs(X[i]-Y[i]) < abs(X[i+1]-Y[i+1]) :
        p4 = abs(X[i+1]-Y[i+1])
    i = i + 1
print(p4)

Submission status: Wrong Answer

Solution code:
import math

def hoge(x, y, p):
    s = 0
    for x_i, y_i in zip(x, y):
         s += math.pow(math.fabs(x_i - y_i), p)
    return math.pow(s, 1/p)

_ = input()
x = [int(e) for e in input().split()]
y = [int(e) for e in input().split()]
print (hoge(x, y, 1))
print (hoge(x, y, 2))
print (hoge(x, y, 3))
print (hoge(x, y, math.inf))

Submission status: Wrong Answer

Solution code:
import math

def hoge(x, y, p):
    s = 0
    for x_i, y_i in zip(x, y):
         s += math.pow(math.fabs(x_i - y_i), p)
    return math.pow(s, 1/p)

_ = input()
x = [int(e) for e in input().split()]
y = [int(e) for e in input().split()]
print (hoge(x, y, 1))
print (hoge(x, y, 2))
print (hoge(x, y, 3))
print (hoge(x, y, 1000))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
for p in [1.0, 2.0, 3.0]:
    a = 0
    for i in range(n):
        a += abs(x[i] - y[i]) ** p
    D = a ** (1/p)
    print(D)
inf_D = float("inf")
for i in range(n):
    if abs(x[i] - y[i]) < inf_D:
        inf_D = abs(x[i] - y[i])
print(inf_D)

Submission status: Wrong Answer

Solution code:
from math import fabs, sqrt

n = int(input())
x = list(map(float, input().strip().split()))
y = list(map(float, input().strip().split()))

sum1 = 0
sum2 = 0
sum3 = 0
pil = []

for i in range(n):
    sum1 += fabs(x[i] - y[i])
    sum2 += fabs(x[i] - y[i]) ** 2
    sum3 += fabs(x[i] - y[i]) ** 3
    pil.append(x[i] - y[i])

pil = sorted(pil)
p1 = sum1
p2 = sqrt(sum2)
p3 = sum3 ** (1 / 3)
pi = pil[n-1]

print(p1)
print(round(p2, 6))
print(round(p3, 6))
print(pi)