java
\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        int q=0;\n        HashSet<String> set=new HashSet<>();\n        for(int i=
```\nclass Solution {\n    public int countDistinct(int[] nums, int k, int p) {\n        int q=0;\n        HashSet<String> set=new HashSet<>();\n        for(int i=0;i<nums.length;i++){\n              String s="";\n            for(int j=i;j<nums.length;j++){\n                  if(nums[j]%p==0)\n                      q++;\n                  if(q>k)\n                     break;\n                  s=s+\',\'+nums[j];\n                  set.add(s);      \n            }\n            q=0;   \n        }  \n       return set.size();\n    }\n}\n```\n
['String', 'Java']