Submit | All submissions | Best solutions | Back to list |
HS09APR - Approximation |
Given coordinates (Xi, Yi ) of N points of the plane, calculate the coefficients A, B, C, and D of the polynomial W(X)=A*X3 + B*X2 + C*X + D, such that value of the function
F(X)=(Y1 – W(X1))2 + (Y2 – W(X2))2 + … + (YN – W(XN))2 is minimized.
Input
The first line of input consists of a single positive integer N (5<=N<=50), representing the number of points. Each of the following N lines contains the coordinates Xi, Yi (-1000<= Xi, Yi <=1000), given with two digits precision after the decimal dot.
Output
Output a single line containing the coefficients A, B, C, D of the sought polynomial, separated by spaces. Print all numbers with two digits precision after the decimal dot.
Example
Input: 9 -4.00 -74.00 -3.00 -26.00 -2.00 0.00 -1.00 10.00 0.00 10.00 1.00 6.00 2.00 4.00 3.00 10.00 4.00 30.00 Output: 1.00 -2.00 -3.00 10.00
Scoring
For solving this problem you will score 10 points.
Added by: | Adam Dzedzej |
Date: | 2009-09-15 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TCL TEXT WHITESPACE |
Resource: | Thanks to Talent Association (www.talent.edu.pl) |