Polynomial Summation
Time Limit: 5 Seconds Memory Limit: 32768 KB
Calculate the summation of polynomial P(x) over integers in [a, b].
Input
Each test case starts with an integer n (0 <= n <= 10) on a line, which is the degree of P(x).
The second line contains n+1 integers, Cn, Cn-1, ..., C1, C0, (|Ci| <= 1000), which are the coefficients of P(x).
The third line contains two integers a and b, (-1,000,000 <= a <= b <= 1,000,000), the range of the summation.
Process to the end of file.
Output
One number for each case. The format is [-]x.xxxxxxe+xx. Note that printf("%.6e\n",ans) generates this format in g++ compiler.
Sample Input
1 1 0 5 1000 4 1 0 0 0 0 999999 1000000
Sample Output
5.004900e+05 1.999996e+24Submit
Source: ZOJ Monthly, January 2003