P2527 [SHOI2001] Panda's Trouble
Description
panda is a math geek who loves studying things that go against the grain. Recently, he has been looking into sieve methods. As is well known, after applying a sieve to integers in a range, the remaining numbers are all primes. But panda is not interested in those; he is only interested in the numbers that get crossed out. He believes that important cosmic secrets are hidden among these eliminated numbers, which people just have not discovered yet.
panda also thinks that simply sieving in ascending order is not enough to reveal the mystery, so he decides to study numbers that contain at most certain prime factors (for example, the numbers that contain at most the prime factors $2,3$ are $2,3,4,6,8,9,\ldots$). He needs to obtain the $k$-th smallest among such numbers ($k$ is what panda calls the cosmic coefficient). Please write a program to help him find this number.
Input Format
The first line contains two integers $n,k$, where $n$ is the number of prime factors, and $k$ is that cosmic coefficient.
The second line contains $n$ integers, representing these $n$ prime factors. Let the sequence formed by these primes be $p$.
Output Format
Output a single line: the $k$-th smallest positive integer that contains at most these $n$ prime factors. Denote this answer by $ans$.
Explanation/Hint
#### Sample explanation
The first six numbers are $3,5,9,15,25,27$.
#### Constraints
For all testdata, $1\le n\le 100$, $1\le k\le 10^5$, $p_i\in\text{prime}$, $p_i\le 10^3$, $p_i\not=p_j(i\not=j)$, $1\le ans\le 2\times 10^9$.
Translated by ChatGPT 5