Root Solver
Write a program that solves for the root of a univariate polynomial with a maximum degree of 100.
Input Format
Line 1 of the input contains an integer T (1 ≤ T ≤ 101), indicating the number of terms in the polynomial.
The next T lines each contain a real number coefficient and a whole number exponent from 0 to 100 inclusive.
Terms will always be collected (i.e. exponents will not be repeated) and arranged in descending powers.
Output Format
In order from lowest value to highest value, every real solution for when the polynomial is equal to zero.
Your answer must be accurate within ±10-5 in absolute and relative error.
If there are no real solutions to the equation, output "NO REAL ROOTS".
Note: Coefficients and answers can have up to 18 digits, and will fit inside a long double.
Sample Input 1
2 2 3 -54 0
Sample Output 1
3
Explanation
This asks for the solution(s) of x for the equation .
Sample Input 2
3 3 2 4 1 -20 0
Sample Output 2
-3.33333 2
Explanation
This asks for the solution(s) of x for the equation .
All Submissions
Best Solutions
Point Value: 30 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Jul 28, 2012
Author: Alex
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
But good, I didn't expect my program to actually work right away.
If this is really what's intended, then the problem statement should reflect it, and the point value should be reduced. Otherwise, larger cases should be added.