Inaho IV

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

Inaho has just realized he can travel diagonally, and also that density has nothing to do with how fast he can travel. He very much appreciates your help for trying to walk him through space, but he no longer needs your instructions. He now only needs the direct distance from his current position to his destination. As he still cannot understand the complexities of N-dimensions, please help him (for the last time, we promise)!

Given his current position and his destination point, find the direct distance if he is able to travel diagonally.

Input Specification

The first line will contain the integer N (1 \le N \le 1000), the number of dimensions.

The second line will contain N decimal values (a_1, a_2, \ldots, a_N) (0 \le a_i \le 10^8) which are the coordinates of his current position.

The third line will contain N decimal values (b_1, b_2, \ldots, b_N) (0 \le b_i \le 10^8) which are his destination coordinates.


For 1 of the 7 available marks, N \le 3.

For an additional 1 of the 7 available marks, a_i, b_i < 1001.

Output Specification

Output the direct distance from a to b.

Outputs with a relative or absolute error of 10^{-6} will be accepted.

Sample Input 1

1.0 1.0 
2.0 2.0

Sample Output 1


Sample Input 2

1.5 2.5 4.0
0.2 5.0 0.0

Sample Output 2

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation.


There are no comments at the moment.