C++ DP using unordered_map
\nint numFactoredBinaryTrees(vector<int>& A) {\n        int n = A.size();\n        if(n==0) return 0;\n        unordered_map<int,long long int> dp; // key is th
```\nint numFactoredBinaryTrees(vector<int>& A) {\n        int n = A.size();\n        if(n==0) return 0;\n        unordered_map<int,long long int> dp; // key is the product, value is the count\n        sort(A.begin(), A.end());\n        dp[A[0]] = 1;\n        for(int i=1; i<n; i++) {\n            dp[A[i]] = 1;\n            for(auto it=dp.begin(); it!=dp.end(); it++) {\n                int p1 = it->first;\n                if(A[i] % p1 != 0) continue;\n                int p2 = A[i] / p1;\n                if(!dp.count(p2)) continue;\n                dp[A[i]] += it->second * dp[p2];\n                dp[A[i]] %= 1000000007;\n            }\n        }\n        int res = 0;\n        for(auto it=dp.begin(); it!=dp.end(); it++) {\n            res += it->second;\n            res %= 1000000007;\n        }\n        return res;\n    }\n```
[]