Polynomial evaluation (1) P96767


Statement
 

pdf   zip

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 c0c_0, c1c_1, …, cnc_n 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.

Public test cases
  • Input

    2
    3 4 5
    

    Output

    31.0000
    
  • Input

    3
    0 0 10
    

    Output

    90.0000
    
  • Input

    -2.5
    1 -2 0 5.4
    

    Output

    -78.3750
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Haskell Java Python Rust