P1024 [NOIP 2001 Senior] Solving a Univariate Cubic Equation

Description

Given a cubic equation of the form $a x^3 + b x^2 + c x + d = 0$. You are given the coefficients of the equation (where $a, b, c, d$ are real numbers). It is guaranteed that the equation has three distinct real roots, the roots lie in the range $-100$ to $100$, and the absolute difference between any two roots is $\ge 1$. Output the three real roots in increasing order on a single line (separated by spaces), each to exactly 2 decimal places. Hint: Let the equation be $f(x) = 0$. If there exist two numbers $x_1$ and $x_2$ with $x_1 < x_2$ and $f(x_1) \times f(x_2) < 0$, then there is a root in the interval $(x_1, x_2)$.

Input Format

One line containing $4$ real numbers $a, b, c, d$.

Output Format

One line containing $3$ real roots in increasing order, each to exactly $2$ decimal places.

Explanation/Hint

- If $x_1 < x_2$ and $f(x_1) \times f(x_2) < 0$, then there is a root in $(x_1, x_2)$. - Source: NOIP 2001 Senior, Problem 1. Translated by ChatGPT 5