Created
July 5, 2016 15:57
-
-
Save tilakpatidar/45043aee1ff7a8c65f1253db2d552240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def value(k, degree, coefficients): | |
ans = 0 | |
prev = 1 | |
for i in xrange(degree+1): | |
if i != 0: | |
prev = prev * k | |
ans += coefficients[i] * prev | |
return ans | |
degree = input() | |
coefficients = map(int,raw_input().split()) | |
t=input() | |
while t!=0: | |
t-=1 | |
print value(input(), degree, coefficients) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment