Clean and easy to understand C++ code using Set
\nclass Solution {\npublic:\n    struct hashFunction \n    {\n      size_t operator()(const vector<int> \n                        &myVector) const \n      {\n  
```\nclass Solution {\npublic:\n    struct hashFunction \n    {\n      size_t operator()(const vector<int> \n                        &myVector) const \n      {\n        std::hash<int> hasher;\n        size_t answer = 0;\n\n        for (int i : myVector) \n        {\n          answer ^= hasher(i) + 0x9e3779b9 + \n                    (answer << 6) + (answer >> 2);\n        }\n        return answer;\n      }\n    };\n    int countDistinct(vector<int>& nums, int k, int p) {\n        unordered_set<vector<int>, hashFunction> dist;\n        \n        for (int i  = 0; i < nums.size(); i++) {\n            vector<int> t; // create a temporary vector each time to insert in the set\n            int count = 0; // count should be 0 after each inner loop iteration finishes\n            for (int j = i; j < nums.size(); j++) {\n                t.push_back(nums[j]);\n                if (nums[j] % p == 0) count++; // count number elements divisible by p\n                if (count <= k) {\n                    dist.insert(t);\n                }\n                else if (count > k) break; // if number of elements divisible by p is more than k then no point to traverse further, break\n            }\n        }\n        \n        return (int)dist.size();\n    }\n};\n```
['Ordered Set']