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
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.