Polynomial
Time limit1sMemory limit128 MB
Given a degree-n polynomial's values at 0 through n, compute its value at n+1.
- Level
Medium6 of 10
- Topics
- Math, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
A polynomial of degree at most is given by its values at the points . Your task is to determine the value of this polynomial at the point .
Write a program that:
- reads the (maximum) degree of the polynomial and its values at the points ,
- computes the value of the polynomial at the point ,
- prints the result.
Input
The first line contains one positive integer , the (maximum) degree of the polynomial, with . Each of the next lines contains one integer: the values of the polynomial at the successive points, where . For every input the requested result is an integer.
Output
Print a single integer: the value of the polynomial at the point .