All problems

Intercept of the Best-Fit Line

easyPythonRegression

Tessellate Software bills its customers a flat monthly base charge plus a fee for each extra seat, but the pricing page was rewritten last year and nobody can find what the base charge is any more. A sample of current customers' extra-seat counts and monthly bills is on hand, paired by position. The same recovery has to be done for every product line, and only some of those samples happen to include a customer with no extra seats at all.

Finance needs the base charge recovered from the billing data so the new pricing page can state it.

Task: Print the intercept of the least-squares straight line predicting the bill from the seat count — the value that line takes at a seat count of zero — rounded to 2 decimals.

Input

Three lines. The first holds one integer n, the number of sampled customers (at least 2). The second holds the n extra-seat counts, separated by spaces. The third holds the n monthly bills in dollars, in the same customer order. Values are decimal numbers, and the seat counts are not all the same.

Output

One line holding the base charge, rounded to 2 decimals and printed the way Python prints a float — 5.0, never 5.00.

Example:

Input:
5
0 1 2 3 4
5 7 9 11 13

Output:
5.0

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…