#101. 一元三次方程求解
一元三次方程求解
Description
Consider an equation of the form: ax3+bx2+cx+d=0, which is a cubic equation in one variable. Given the coefficients of the equation (a, b, c, d are all real numbers), it is agreed that the equation has three distinct real roots (the roots are in the range of -100 to 100), and the absolute difference between any two roots is ≥ 1. The three real roots are required to be output in the same line in ascending order (with a space between the roots), accurate to two decimal places.
Hint: Let f(x)=0 denote the equation. If there exist two numbers x1 and x2 such that x1 < x2 and f(x1)*f(x2) < 0, then there must be a root between (x1, x2).
Input Format
Each test file contains only one set of test data. Each set of input consists of four real numbers a, b, c, d, representing the coefficients of the cubic equation.
Output Format
For each set of input data, output the three real roots in the same line in ascending order (with a space between the roots), accurate to two decimal places.
Sample
1 -5 -4 20-2.00 2.00 5.00