[Python] Count distinct subarrays
\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        N = len(nums)\n        substrings = set()\n        \n        de
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        N = len(nums)\n        substrings = set()\n        \n        def subarray(idx, curr, s):\n            if idx == N:\n                return 0\n            \n            curr += nums[idx]%p == 0\n            s += str(nums[idx])+","\n            if curr <= k:\n                not_exists = s not in substrings\n                substrings.add(s)\n                return not_exists + subarray(idx+1, curr, s)\n            else:\n                return 0            \n            \n        res = 0\n        for idx in range(N):\n            res += subarray(idx, 0, "")\n        return res\n```
['Python']