input = [1,2,3,4]
# output = [24,12,8,6]
input = [5,3,2,4,1]
# output = [24,40,60,30,120]
length = len(input)
a = b = []
for index in range(length):
r=1
for i in input[:index]:
r *= i
a.append(r)
r=1
for i in input[length-index-1:]:
r *= i
b.append(r)
b.reverse()
b = b + [1]
_ = b.pop(0)
# print(a)
# print(b)
print(list(map(lambda x, y: x * y, a, b)))
这种算是知道就会,不知道也很难想出来的吧?