POLEVAL  Evaluate the polynomial
Your task consists of evaluate a polynomial of degree n (0 <= n <= 999) represented by its n+1 coefficients of the form:
in each one of the k (1 <= k <= 100) points x_{1}, x_{2}, …, x_{k}. The coefficients of the polynomial and the values where they will be evaluated are integers in the interval [100, 100] that guarantees that the polynomial's evaluation is at the most 2^{63} – 1.
Input
There will be multiple test cases, each one with 4 lines that are described below
n: degree of polynomial.
c_{n} c_{n1 }… c_{2 } c_{1} c_{0}: coefficients of the polynomial separated by a single space.
k: number of points to evaluate the polynomial.
x_{1} x_{2 }…_{ } x_{k1} x_{k}: points to evaluate the polynomial separated by a single space.
The final test case is a single line where n = 1 and this case should not be processed.
Output
For each test case you should print k + 1 lines of output, the very first line containing the case number and the following k lines with the result of the polynomial's evaluation in each one of the k given points. See the sample.
Example
Input: 2
1 2 1
5
0 1 1 2 2
3
2 1 2 1
4
0 1 2 2
1
Output: Case 1:
1
2
2
1
7
Case 2:
1
0
15
9
hide comments
angshuman_03:
20200422 16:31:32
AC in one Go!


nadstratosfer:
20191211 02:52:32
Possible with pure Python, albeit just at the limit (same solution that got AC, TLEs sometimes). Code too short to talk about any optimizations. Pythonists are advised to use PyPy here. 

wrzoboo:
20180709 12:19:12
Basically unsolvable with Python3, Horner + optimization = TLE 

prabhat236218:
20171130 18:00:10
simple implement


kaushalag29:
20170518 19:51:09
AC in one GO


ajeetk_973:
20170407 11:02:35
implement horner & get AC 

nilabja16180:
20170405 09:44:40
Naive approach works fine, AC in ONE GO! 

anurag_lal1:
20170108 08:18:07
Using Naive approach got TLE but AC using Horner's method :)


rahadiankputra:
20161002 07:50:24
Simple yet very, very beautiful problem :D 

vineetpratik:
20160622 10:13:48
if you get TLE ,

Added by:  Ivan Alfonso Olamendy 
Date:  20070825 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: C99 ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  My own resource 