✅ Python - Simple Count all combinations
\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        n = len(nums)                        \n        sub_arrays = set
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        n = len(nums)                        \n        sub_arrays = set()\n        \n\t\t# generate all combinations of subarray\n        for start in range(n):\n            cnt = 0\n            temp = \'\'\n            for i in range(start, n):\n                if nums[i]%p == 0:\n                    cnt+=1                 \n                temp+=str(nums[i]) + \',\' # build the sequence subarray in CSV format          \n                if cnt>k: # check for termination \n                    break\n                sub_arrays.add(temp)                                    \n                \n        return len(sub_arrays)\n```\n\n**T = O(N^3)**\n**S = O(N^2)**\n\n---\n\n***Please upvote if you find it useful***
['Python', 'Python3']