eolymp
bolt
Try our new interface for solving problems
Məsələlər

Solutions of Cubic Equation

Solutions of Cubic Equation

Zaman məhdudiyyəti 2 saniyə
Yaddaşı istafadə məhdudiyyəti 128 MiB

Hannah asked you to determine all distinct real solutions of a cubic equation in the following form:

Ax^3 + Bx^2 + Cx + D = 0

The task is quite complicated especially if one solution is irrational. Before you complained, Hannah told you that she'll only give cubic equations with at least one integer solution.

Your task then is to find all distinct real solutions of the cubic equation given the coefficients A, B, C, and D where A is not 0.

The range of values of A, B, C, and D is -2000000 to 2000000. The range of values of x is -1000000 to 1000000.

Giriş verilənləri

The input starts with an integer N (where 0 < N < 100). It is then followed by N input lines. Each input line consists of four numbers A, B, C, and D, not necessarily integers. A is never 0.

Çıxış verilənləri

For each input line, print all distinct real solutions of the cubic equation in one line, sorted in increasing order. Each real solution must be rounded off to the nearest ten thousandth and must be printed with exactly four digits after the decimal point. Two or more distinct real solutions must be separated by exactly one space.

Nümunə

Giriş verilənləri #1
3
1.5 -5 2 -1.5
2 -7 7 -2
2 0 0 0
Çıxış verilənləri #1
3.0000
0.5000 1.0000 2.0000
0.0000
Mənbə ACM ICM Philippines Multi-Provincial Programming Contest 2013