Skip to content

Instantly share code, notes, and snippets.

@tilakpatidar
Created July 5, 2016 15:57
Show Gist options
  • Save tilakpatidar/45043aee1ff7a8c65f1253db2d552240 to your computer and use it in GitHub Desktop.
Save tilakpatidar/45043aee1ff7a8c65f1253db2d552240 to your computer and use it in GitHub Desktop.
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