Clear c++ solution inspired by Ugly Number II
int nthSuperUglyNumber(int n, vector<int>& primes) {\n    \tint k = primes.size();\n    \tvector<int> pos(k, 0);\n    \tvector<int> res(n);\n    \tres[0] = 1;\n
    int nthSuperUglyNumber(int n, vector<int>& primes) {\n    \tint k = primes.size();\n    \tvector<int> pos(k, 0);\n    \tvector<int> res(n);\n    \tres[0] = 1;\n    \tfor (int i = 1; i < n; i++) {\n    \t\tint temp = INT_MAX;\n    \t\tfor (int j = 0; j < k; j++) \n    \t\t\ttemp = min(temp, res[pos[j]] * primes[j]);\n    \t\tfor (int j = 0; j < k; j++) {\n    \t\t\tif (temp == res[pos[j]] * primes[j])\n    \t\t\t\tpos[j]++;\n    \t\t}\n    \t\tres[i] = temp;\n    \t}\n    \treturn res[n - 1];\n    }
[]