90. Distance Between Two Points
Foundation1000 ms256 MBSolved by 0%
A point has an x and a y coordinate.
Read two points — four integers on one line, x1 y1 x2 y2 — and print the squared
distance between them.
Squared, so the answer stays a whole number:
(x2 − x1)² + (y2 − y1)²
Constraints - `-1000000 ≤ each coordinate ≤ 1000000`
Input
A single line containing four integers x1 y1 x2 y2, separated by spaces.
Output
Print one integer — the SQUARED distance between the points.
Input0 0 3 4
Output25
Noteis the 3-4-5 triangle, so the squared distance is 25
Input1 1 1 1
Output0
Noteis the same point twice, so the distance is zero
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution