Easy C++ Solution | Set | O(n^2)
Complexity\n- Time complexity: O(n^2)\n\n# Code\n\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        int n = nums.siz
# Complexity\n- Time complexity: O(n^2)\n\n# Code\n```\nclass Solution {\npublic:\n    int countDistinct(vector<int>& nums, int k, int p) {\n        int n = nums.size();\n\n        // creating a set for storing distinct subarrays \n        // which have atmost k elements divisible by p\n        set<vector<int>> st;\n\n        for(int i = 0; i < n; i++){\n            // counting the number of element \n            // which are divible by p \n            int count = 0;\n\n            // subarray\n            vector<int> vec;\n\n            for(int j = i; j < n; j++){\n                vec.push_back(nums[j]);\n                if(nums[j] % p == 0){\n                    count++;\n                }\n                // storing the subarray if the count of elements\n                // divisible by p are atmost k\n                if(count <= k){\n                    st.insert(vec);\n                } else {\n                    break;\n                }\n            }\n        }\n        return st.size();\n    }\n};\n```
['C++']