Title: Distance II

Your task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.

Minkowski's distance is defined as:
Dxy = (Σi=1 to n |xi - yi|^p)^(1/p)

It can be the Manhattan distance:
Dxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|
where p = 1.

It can be the Euclidean distance:
Dxy = √((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)
where p = 2.

It can also be the Chebyshev distance:
Dxy = max(|xi - yi|)
where p = ∞

Write a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and ∞, respectively.

Input:
The first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.

Output:
Print the distances for p = 1, 2, 3, and ∞ in a line, ensuring the output has an absolute error less than 10^-5.

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

# Buggy version:
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))


# Fixed version:
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.333333333333333333))
print('{:.6f}'.format(inf))

# Buggy version:
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))

# Fixed version:
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(vx[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))

# Buggy version:
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)

# Fixed version:
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)

# Buggy version:
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) ] ) ) )
 

# Fixed version:
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) ] ) ) )

# Buggy version:
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) ] ) ) )
 

# Fixed version:
n = int(input())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
# p=1,2,3
for p in range(1,4):
    print("{0:.6f}".format(sum([abs(a-b)**p for a,b in zip(X,Y)])**(1/p)))
# p=infinity
print("{0:.6f}".format(max([abs(a-b) for a,b in zip(X,Y)])))