All problems

Recomputing a Centroid

easyPythonK-Means Clustering

With the file booked, Wexford Couriers wants to know where each locker really ought to sit. A shortlist position was only a planner's guess; the addresses booked to it now say where its customers actually are. What the planners want is the balance point of those addresses -- the spot with as much customer weight pulling one way as the other, on each axis. In this work that balance point has a name: the centroid. One site's booked addresses are given below.

Task: Print the centroid of the addresses booked to this site.

Input

The first line holds one integer n, the number of addresses booked to this site, always at least 1. Each of the next n lines holds one address's two map coordinates, separated by a single space.

Output

Two lines. First mean_x, a single space, and the centroid's east-west coordinate rounded to 2 decimal places. Then mean_y, a single space, and its north-south coordinate, also to 2 decimal places. Each axis is settled on its own, using every booked address.

Example:

Input:
3
0 0
2 0
1 3

Output:
mean_x 1.00
mean_y 1.00

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…