标签:
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; }
标签:
原文地址:http://www.cnblogs.com/raichen/p/5853218.html