C++ using SET clean code
\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        // generate all subsets and then count\n        set<string>s;// t
```\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        // generate all subsets and then count\n        set<string>s;// to store unique subarr(contiguous)\n        for(int i=0;i<nums.size();i++)\n        {\n            int cnt(0);\n            string currstr=""; // stores subarray starting from index i. \n            for(int j=i;j<nums.size();j++)\n            {\n                currstr+=nums[j]+\'0\'; // Appending charcter with nums[j] ascii value.\n                                      // \'0\' + 1 = 49 == \'1\'\n                if(nums[j]%p==0)cnt++;\n                // if the current array have at most k elements divisible by  then add it to the set.\n                if(cnt<=k)\n                s.insert(currstr);\n            }\n            \n        }\n        return s.size();\n    }\n    \n};\n```
['C', 'Ordered Set']