Faster than 99.6%, simple C++ Solutiion
\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        vector<int> v(nums.size(), 0);\n        for(int i=0; i<nums.size(
```\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        vector<int> v(nums.size(), 0);\n        for(int i=0; i<nums.size(); i++)\n        {\n            for(int j=i+1; j<nums.size(); j++)\n            {\n                int x=i, y=j, cnt=0;\n                while(y<nums.size() && nums[x]==nums[y])\n                {\n                    x++; y++;\n                    cnt++;\n                }\n                v[j]=max(v[j], cnt);\n            }\n        }\n        int res=0;\n        for(int i=0; i<nums.size(); i++)\n        {\n            int cnt=0, can=0;\n            for(int j=i; j<nums.size(); j++)\n            {\n                if(nums[j]%p==0)\n                    cnt++;\n                if(cnt>k)\n                    break;\n                if(v[i]--<=0)\n                    res++;\n            }\n        }\n        return res;\n    }\n};\n```
[]