Python. Faster than 91%.... Hashing..
\nclass Solution:\n    def countDistinct(self, x: List[int], k: int, p: int) -> int:\n        prime=10**9+7\n        l=len(x)\n        se=set()\n        for i i
```\nclass Solution:\n    def countDistinct(self, x: List[int], k: int, p: int) -> int:\n        prime=10**9+7\n        l=len(x)\n        se=set()\n        for i in range(l):\n            c=0\n            q=0\n            for j in range(i,l):\n                if x[j]%p==0:\n                    c+=1\n                q=q*prime+x[j]\n                if c<=k:\n                    se.add(q)\n                else:\n                    break\n        return len(se)\n```
[]