All problems

Euclidean Distance in Many Dimensions

easyPythonK-Nearest Neighbors

Marlow Roastery grades every batch of coffee on the same fixed set of laboratory readings — acidity, body, sweetness and the rest — so a batch is stored as a row of numbers, one per reading. The lab wants one number saying how far apart two batches are overall. Every reading counts the same as every other, and when a batch happens to be described by only two readings the answer must agree with plain straight-line distance on a map.

Task: Print the straight-line distance between the two rows of readings.

Input

Three lines. The first holds a single integer n, the number of readings. The second holds the first batch's n readings separated by single spaces. The third holds the second batch's n readings, in the same order. Readings may be negative or fractional.

Output

One line holding the distance, written with exactly 4 digits after the decimal point.

Example:

Input:
3
1 2 3
4 6 3

Output:
5.0000

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…