Python (Simple Maths)
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```python3 []
class Solution:
    def countDistinct(self, nums, k, p):
        n, left, count, res = len(nums), 0, 0, set() 

        for right in range(n):
            if nums[right]%p == 0: 
                count += 1

            while count > k:
                if nums[left]%p == 0: 
                    count -= 1

                left += 1

            ans = nums[left:right+1] 

            for i in range(len(ans)):
                res.add(tuple(ans[i:]))

        return len(res)
```
['Python3']