class Solution {
public:
vector<int> multiply(const vector<int>& A) {
if (A.empty() || A.size() == 1) {
return std::vector<int>();
}
std::vector<int> res(A.size(), 1);
// 得出下三角
for (int i = 1; i < A.size(); ++i) {
res[i] = res[i - 1] * A[i - 1];
}
int tmp = 1;
// 上三角
for (int i = A.size() - 1; i >= 0; --i) {
res[i] *= tmp;
tmp *= A[i];
}
return res;
}
};