Very short and simple C++ priority_queue Sol.
please upvote, if you like the question\n```\ntypedef long long ll;\nll mod = 1000000007;\n#define f first\n#define s second\n#define ss string\n#define mp make
please upvote, if you like the question\n```\ntypedef long long ll;\nll mod = 1000000007;\n#define f first\n#define s second\n#define ss string\n#define mp make_pair\n#define pb push_back\n#define p pair<int, int>\n#define pp pair<int, p>\n#define v vector<int>\n#define vl vector<ll>\n#define vb vector<bool>\n#define vs vector<string>\n#define vp vector<p>\n#define vpp vector<pair<int, p>>\n#define vv vector<v>\n#define vvl vector<vl>\n#define vvp vector<vp>\n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define repa(i, a, n) for(int i = a; i <= (n); ++i)\n#define repd(i, n) for(int i = n; i >= 0; --i)\n#define all(x) (x).begin(), (x).end()\n\nclass Solution {\npublic:\n    int nthSuperUglyNumber(int n, vector<int>& a) {\n        if(n == 0){\n            return -1;\n        }\n        if(n == 1){\n            return 1;\n        }\n        if(a.size() == 1){\n            return pow(a[0], n-1);\n        }\n        priority_queue<ll, vl, greater<ll>> q;\n        for(int i : a){\n            q.push(i);\n        }\n        ll ans, count = 1;\n        while(count < n){\n            ans = q.top();\n            q.pop();\n            if(ans != q.top()){\n                count++;\n                for(int i : a){\n                    q.push(i*ans);\n                }\n            }\n        }\n        return ans;\n    }\n};
[]