java
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int numFactoredBinaryTrees(int[] arr) {\n        Map<Integer, Long> mp = new HashMap<>();\n        long res = 1;\n        Arrays.sort(arr);\n        mp.put(arr[0], res);\n        \n        for (int k = 1; k < arr.length; k++) {\n            long sum = 1;\n            for (int i = 0; i < k; i++) {\n                if (arr[k] % arr[i] == 0 && mp.containsKey(arr[k] / arr[i])) {\n                    sum += (mp.get(arr[k] / arr[i]) * mp.get(arr[i]));\n                }\n            }\n            mp.put(arr[k], sum);\n            res += sum;\n        }\n        \n        return (int) (res % 1_000_000_007);\n    }\n}\n```
['Java']