#P1024. Finding the Roots of a Cubic Equation
Finding the Roots of a Cubic Equation
Finding the Roots of a Cubic Equation
Given a cubic equation of the form \(ax^3 + bx^2 + cx + d = 0\), where \(a, b, c, d\) are real numbers, and it is guaranteed that the equation has three distinct real roots in the range \([-100, 100]\) with the absolute difference between any two roots being no less than 1, your task is to find all three roots.
Output the three roots in increasing order on the same line, with each root printed to exactly 2 decimal places and separated by a space.
Hint: For a continuous function \(f(x)\), if there exist two numbers \(x_1\) and \(x_2\) (with \(x_1 < x_2\)) such that \(f(x_1) \times f(x_2) < 0\), then there is at least one root in the interval \((x_1, x_2)\).
inputFormat
The input consists of four space-separated real numbers \(a, b, c, d\) representing the coefficients of the cubic equation \(ax^3 + bx^2 + cx + d = 0\).
outputFormat
Print the three roots in increasing order on one line. Each root must be printed with exactly 2 decimal places and separated by a single space.
sample
1 -6 11 -6
1.00 2.00 3.00