C++ DP solution with Two Pointer
Use two pointer to find out all combinations that product is A[i]. ``` class Solution { public:     int numFactoredBinaryTrees(vector& A) {         long mod = 1
Use two pointer to find out all combinations that product is A[i].
```
class Solution {
public:
    int numFactoredBinaryTrees(vector<int>& A) {
        long mod = 1000000007;
        sort(A.begin(), A.end());
        vector<long> dp(A.size());
        
        int result = 0;
        for (int i = 0; i < dp.size(); ++i) {
            dp[i] = 1;
            int begin = 0;
            int end = i-1;
            while (begin <= end) {
                if (A[begin]*A[end] > A[i]) {
                    end--;
                } else if (A[begin]*A[end] < A[i]) {
                    begin++;
                } else {
                    dp[i] = (dp[i] + (dp[begin]*dp[end])*(begin == end ? 1 : 2)) % mod;
                    begin++;
                }
            }
            result  = (result + dp[i]) % mod;
        }
        return result;
    }
};
```
[]