2013-04-17 14:34:39 +08:00

31 lines
511 B
Python

def poly(x, coef):
out = 0
for i in coef:
out = out * x + i
return out
un = (1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1)
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in xrange(len(a)):
a[i] = poly(a[i], un)
total = 0
for length in xrange(2, len(a) + 1):
y = a[:length]
n = len(y)
L = 0
for k in xrange(n):
l = 1
for xi in xrange(n):
if xi != k:
l *= (n - xi)
for xi in xrange(n):
if xi != k:
l /= (k - xi)
L += (l * y[k])
total += L
print total + 1