C++ Dynamic Programming O(n*k)
\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> dp(n, INT_MAX);\n        int m = primes.size();\n    
```\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& primes) {\n        vector<int> dp(n, INT_MAX);\n        int m = primes.size();\n        dp[0] = 1;\n        vector<int> last(m, 0);\n        for(int i = 1; i < n; i++){\n            for(int k = 0; k < m; k++){\n                dp[i] = min(dp[i], dp[last[k]]*primes[k]);\n            }\n            for(int k = 0; k < m; k++){\n                if(dp[i] == dp[last[k]]*primes[k]) last[k]++;\n            }\n        }\n        return dp[n-1];\n    }\n};\n```
[]