Python | Easy to Understand
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        used = set()\n        n = len(nums)\n        count = 0\n    
```\nclass Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        used = set()\n        n = len(nums)\n        count = 0\n          \n        for i in range(n):\n            divisible_num = 0\n            s = []\n            for j in range(i, n):\n                if nums[j] % p == 0:\n                    divisible_num += 1\n                \n                if divisible_num <= k:\n                    s.append(nums[j])\n                    if tuple(s) not in used:\n                        used.add(tuple(s))\n                        count += 1\n                    else:\n                        continue\n                \n                elif divisible_num > k:\n                    break\n            \n        return count\n
['Python', 'Python3']