Polynomial evaluation (2)

Write a program that reads a number xx and a polynomial p(z)=c0z0+c1z1++cnznp(z) = c_0 z^0 + c_1 z^1 + \cdots + c_n z^n, and computes p(x)p(x).

Input

Input consists of a real number xx followed by the description of the polynomial p(z)p(z): the real coefficients cnc_n, cn1c_{n-1}, …, c0c_0 in this order. (The first sample input/output corresponds to the evaluation of p(z)=3+4z+5z2p(z) = 3 + 4z + 5z^2 at x=2x = 2.)

Output

Print p(x)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