#P2527. [SHOI2001] Panda的烦恼
[SHOI2001] Panda的烦恼
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 are ). He needs to obtain the -th smallest among such numbers ( 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 , where is the number of prime factors, and is that cosmic coefficient.
The second line contains integers, representing these prime factors. Let the sequence formed by these primes be .
Output Format
Output a single line: the -th smallest positive integer that contains at most these prime factors. Denote this answer by .
2 7
3 5
45
Hint
Sample explanation
The first six numbers are .
Constraints
For all testdata, , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号