URI Online Judge | 1015 Distance Between Two Points solve with source code
URI Online Judge | 1015
Distance Between Two Points
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:Distance =
Input
The input file contains two lines of data. The first one contains two double values: x1 y1 and the second one also contains two double values with one digit after the decimal point: x2 y2.
Output
Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.
SOLVE
import math
X1,Y1 = input().split()
X2,Y2 = input().split()
X1 = float(X1)
X2 = float(X2)
Y1 = float(Y1)
Y2 = float(Y2)
Distance = math.sqrt(((X2-X1)*(X2-X1))+((Y2-Y1)*(Y2-Y1)))
print("%.4f"%Distance)
Comments
Post a Comment