factors. Call a number *built* if it is positive and every one of its prime factors appears in factors. The number 1 also counts as built, since it has no prime factors.
List all built numbers in increasing order and return the n-th one (counting from 1).
The answer is guaranteed to fit in a signed 32-bit integer.n=8, factors=[3, 5] → 45
The qualifying numbers in order are 1, 3, 5, 9, 15, 25, 27, 45. The eighth one is 45.
n=6, factors=[2, 11] → 16
The sequence goes 1, 2, 4, 8, 11, 16, so the sixth number is 16.
n=1, factors=[7, 13] → 1
1 has no prime factors at all, so it always comes first.
n ≤ 10⁵factors) ≤ 100factors[i] ≤ 1000factors[i] are prime, distinct and sorted in increasing ordern=8, factors=[3, 5]
45
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.