Measuring Inertia
Wexford Couriers has two rival locker layouts on the table and needs one number that says which is tighter. The measure the planners settled on charges every address for the travel to its own booked site, as the crow flies -- but charges it by the square of that travel rather than the travel itself, so one customer stranded across town costs far more than a handful mildly inconvenienced. The charges are added across the whole city rather than averaged, so a layout covering more addresses is expected to score higher.
Task: Print the layout's total charge.
Input
The first line holds one integer n, the number of addresses. Each of the next n lines holds four numbers separated by single spaces: an address's two map coordinates, followed by the two coordinates of the site it is booked to.
Output
One line holding the total charge across all n addresses, rounded to 4 decimal places. An address sitting exactly on its site contributes nothing.
Example:
Input:
2
1 1 0 0
9 9 10 10
Output:
4.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