C++ || Hashmap || Easy to understand
\nclass Solution {\npublic:\n    int MOD = 1e9 + 7;\n    int numFactoredBinaryTrees(vector<int>& arr) {\n        \n        long ans=0;\n        sort(arr.begin()
```\nclass Solution {\npublic:\n    int MOD = 1e9 + 7;\n    int numFactoredBinaryTrees(vector<int>& arr) {\n        \n        long ans=0;\n        sort(arr.begin(),arr.end());\n        unordered_map<int,long> rootWithCount;\n        \n        for(int i=0;i<arr.size();i++)\n        {\n            long currentAns = 1;\n            for(int j=0;j<i;j++)\n            {\n                if(arr[i]%arr[j])\n                    continue;\n                \n                int a = arr[i]/arr[j];\n                int b = arr[j];\n                \n                currentAns = (currentAns + rootWithCount[a]*rootWithCount[b]%MOD)%MOD;\n            }\n            rootWithCount[arr[i]] = currentAns;\n            ans += currentAns;\n        }\n        return ans%MOD;\n    }\n};\n```
['C']