The chalky smell of a black board is something that will always remind us of those long days spent sitting in our desks taking notes instead of playing outside. If we think about it, life is just a mere blink of an eye in terms of time. But time is a relative thing. sighed our math teacher as he approached a picture of the class picture we took at the beginning of the year. He stood there for a while glaring at the picture... then as usual, he strolled back to his desk and pulled out a shiny new math book. He flipped through the first couple of pages and suddenly stopped.
Let's see who can solve this one...
You are given N number of points. Find a function of the format
f(x)=a*x+b for which
∑((y[i]-f(x[i]))^2) is minimal, where
y[i] are coordinates for the point
N, the number of points is on the first line. The next
Nlines are occupied by pairs of numbers which represent the coordinates of each point.
OutputOn the first line will be the minimum cost, with 10-3 decimal precision, on the only line.
1 ≤ N ≤ 1000
-100 000 ≤ x[i], y[i] ≤ 100 000
The output result is considered correct if and only if the diference between your result and the correct one is less then or equal to 1e-3.