Simple C++ Solution
\nint numFactoredBinaryTrees(vector<int>& arr) {\n        \n        \n        \n        sort( arr.begin() , arr.end() ) ;\n        int n = arr.size() ;\n       
```\nint numFactoredBinaryTrees(vector<int>& arr) {\n        \n        \n        \n        sort( arr.begin() , arr.end() ) ;\n        int n = arr.size() ;\n        int mod = pow( 10 , 9 ) + 7 ;\n        \n        unordered_map< int , long >mp ;\n        int ans = 0 ;\n        for( int i = 0; i < n ; i++ )\n        {\n            mp[arr[i]]++ ;\n        }\n        \n        for( int i = 1  ; i < n ; i++ )\n        {\n            for( int j = 0 ; j < i ; j++ )\n            {\n                \n                if( arr[i]%arr[j]==0 && mp.find(arr[i]/arr[j]) != mp.end())\n                {\n                    mp[arr[i]] = ( mp[arr[i]] + (mp[arr[j]]*(mp[arr[i]/arr[j]]))%mod )%mod  ;\n                }\n            }\n        }\n        \n        for( auto i : mp ) ans = ( ans + i.second )%mod  ;\n        \n        \n        return ans ;\n    }\n```
[]