O(n^2) Tuple counting
Complexity
Time complexity: O(n2)

Space complexity: O(n2)
Code
# Complexity
- Time complexity: $$O(n^2)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(n^2)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def countDistinct(self, nums: List[int], k: int, p: int) -> int:
        subs = set()
        for i in range(len(nums)):
            total, divCount = 0, 0
            sub = ()
            for j in range(i, len(nums)):
                if nums[j] % p == 0:
                    divCount += 1
                if divCount > k:
                    break
                sub += (nums[j],)
                subs.add(tuple(sub))
        return len(subs)
```
['Array', 'Hash Table', 'Rolling Hash', 'Hash Function', 'Enumeration', 'Python3']