Easy C++ Solution O(n*k)
\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> cpr(primes.begin(),primes.end());\n        vector<int
```\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> cpr(primes.begin(),primes.end());\n        vector<int> ind(primes.size(),0);\n        vector<long long> dp(n+1);\n        dp[0]=1;\n        for(int i=1;i<n;i++){\n            long long int m=1e18;\n            for(auto p:primes){\n                m=min(m,(long long)p);\n            }\n            dp[i]=m;\n            for(int j=0;j<primes.size();j++){\n                if(m==primes[j]){\n                    ind[j]++;\n                    primes[j]=dp[ind[j]]*cpr[j];\n                }\n            }\n        }\n        return dp[n-1];\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']