Java bruteforce
\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        // save sub arrays in a string format to count the uniqueness\n        // 
```\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        // save sub arrays in a string format to count the uniqueness\n        // i.e. [3,3,2] is saved as "3-3-2" in the hash set\n        // return the size of the hash set\n        HashSet<String> set = new HashSet<>();\n        for(int i=0; i<nums.length; i++) {\n            for(int j=i; j<nums.length; j++) {\n                int count=0;\n                StringBuilder sb = new StringBuilder();\n                for(int r=i; r<=j; r++) {\n                    sb.append(nums[r]).append("-");\n                    if(nums[r]%p == 0) count++;\n                    if (count>k) break;\n                }\n                if (count<=k) set.add(sb.toString());\n            }\n        }\n        return set.size();\n    }\n}\n```
[]