Java Solution | Brute Force | Set
\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        int count = 0;\n        Set<String> set = new HashSet();\n        int len 
```\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        int count = 0;\n        Set<String> set = new HashSet();\n        int len = nums.length;\n        for(int i = 0; i < len; ++i){\n            int countForK = 0;\n            StringBuilder sub = new StringBuilder();\n            for(int j = i; j < len; ++j){\n                sub.append(nums[j]+ " ");\n                if(nums[j] % p == 0) countForK++;\n                if(countForK > k) break;\n                if(!set.contains(sub.toString())){\n                    count++;\n                    set.add(sub.toString());\n                }\n            }\n\n        }\n        return count;\n    }\n}\n```
['Ordered Set', 'Java']