python
\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        count = 0\n        d = {}\n        \n        for i in range(len
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        count = 0\n        d = {}\n        \n        for i in range(len(nums)):\n            temp = k\n            lst = []\n            \n            for j in range(i, len(nums)):\n                lst.append(nums[j])\n                \n                if nums[j] % p == 0:\n                    temp -= 1\n                \n                if temp >= 0 and not str(lst) in d:\n                    count += 1\n                    d[str(lst)] = 1\n                    \n            \n        return count\n```
[]