vector<int> multiply(const vector<int>& A) { int len = A.size(); vector<int> result(len, 1); result[0] = 1; for (int i = 1; i < len; i++) { result[i] = result[i - 1] * A[i - 1]; //result[i]保存下三角 } int tmp = 1; for (int i = len - 2; i >= 0; i--) { tmp = tmp * A[i + 1]; //tmp保存上三角 result[i] *= tmp; } return result; }
时间: 2024-10-18 17:27:37