Simple JAVA  , Set soln
\n    public int countDistinct(int[] a, int k, int p) {\n        int n =a.length;\n        HashSet<String> hs = new HashSet<>();\n        \n        for(int i=0;
```\n    public int countDistinct(int[] a, int k, int p) {\n        int n =a.length;\n        HashSet<String> hs = new HashSet<>();\n        \n        for(int i=0;i<n;i++)\n        {   \n            String s ="";\n            int count=0;\n            for(int j=i;j<n;j++)\n            {\n               if(a[j]%p==0) count++;\n             \n                if(count>k) break;     \n               \n               s=s+a[j]+";"; \n               hs.add(s); \n            }\n        }\n        return hs.size();\n    }\n```
[]