1 # -*- coding:utf-8 -*- 2 class Solution: 3 def multiply(self, A): 4 n = len(A) 5 mat = [[1 for _ in range(n)]for _ in range(n)] 6 for i in range(n): 7 for j in range(n): 8 if i != j: 9 mat[i][j] = A[j] 10 B = [1] * n 11 for i in range(n): 12 mul = 1 13 for j in range(n): 14 mul *= mat[i][j] 15 B[i] = mul 16 return B 17 # write code here
原文地址:https://www.cnblogs.com/asenyang/p/11025305.html
时间: 2024-10-16 23:27:25