class Solution {
public:
vector<int> multiply(const vector<int>& A) {
if(A.empty()) return vector<int>();
int n = A.size();
vector<int> B(n);
//p代表前i个A[i]的乘积
for(int i = 0, p = 1; i < n; p *= A[i], i++)
B[i] = p;
//判断i是不是大于等于0 ~i来表示 当i==-1时代表~i == 0, 当i表示其他数时~i == 1
//p代表后i个A[i]的乘积
for(int i = n - 1, p = 1; i >= 0; p *= A[i], i--)
B[i] *= p;
return B;
}
};