[Python3] numpy dp
A lot of the complicated looking parts are just small optimizations. There\'s also a lot of crud in here from attempted optimizations that didn\'t end up matter
A lot of the complicated looking parts are just small optimizations. There\'s also a lot of crud in here from attempted optimizations that didn\'t end up mattering, so feel free to learn by cleaning this up.\n\n```python\nimport numpy as np\n\nclass Solution:\n    def countSubMultisets(self, nums: List[int], l: int, r: int, mod: int = 10 ** 9 + 7) -> int:\n        nums = np.array(nums)\n        nonzero = nums[nums != 0]\n        multiplier = (len(nums) - len(nonzero) + 1)\n        unique_nums, counts = np.unique(nonzero, return_counts=True)\n        counts = np.minimum(counts, r // unique_nums)\n        product = unique_nums * counts\n        dp = np.zeros(min(r, np.sum(product)) + 1, dtype=np.int64)\n        dp[0] = 1\n        for x, upper in zip(unique_nums, product + unique_nums):\n            pd = np.zeros_like(dp)\n            for m in np.arange(x, upper, x):\n                pd[m:] += dp[:-m]\n            dp[x:].__iadd__(pd[x:]).__imod__(mod)\n        return dp[l:].sum() * multiplier % mod\n```
[]