0113. Roots of a Polynomial

Имя входного файла: roots.in
Имя выходного файла: roots.out
Ограничение по времени: 5 s
Ограничение по памяти: 64 megabytes

Your task is to find real roots of a given non-zero polynomial.

Input file

The first line of the input file contains an integer number N (1 ≤ N ≤ 10) – degree of the polynomial. The next line contains N+1 integer numbers an an-1a0 (the polynomial is anxn+an-1xn-1+…+a1x+a0). They do not exceed 106 by an absolute value. The last line of the input contains a single integer D (1 ≤ D ≤ 1000) – the required number of digits after decimal point in output. It is guaranteed that all roots of the polynomial are simple.

Output file

Output the real roots with D digits after decimal point in ascending order. Standard rounding rules apply. That is, if the exact D+1-th digit after decimal point is 4 or smaller, the D-th digit in output is rounded downards; otherwise upwards.

Examples:

roots.inroots.out
1 -1 1 11.0


Источник: Petrozavodsk Summer 2003. Primary Contest, Sunday, August 24
Автор: Andrew Lopatin, Nick Durov

Обсудить       Отправить решение



Версия для печати