Polynomial evaluation (2)

Write a program that reads a number x and a polynomial
p(z) = c₀z⁰ + c₁z¹ + ⋯ + c_(n)z^(n), and computes p(x).

Input

Input consists of a real number x followed by the description of the
polynomial p(z): the real coefficients c_(n), c_(n − 1), …, c₀ in this
order. (The first sample input/output corresponds to the evaluation of
p(z) = 3 + 4z + 5z² at x = 2.)

Output

Print p(x) with 4 digits after the decimal point.

Hint

The expected solution uses Horner’s rule.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:43:41.625Z

© Jutge.org, 2006–2026.
https://jutge.org
