#P2723. [USACO3.1] 丑数 Humble Numbers
[USACO3.1] 丑数 Humble Numbers
Description
Given a set of primes , consider the set of positive integers whose prime factors all belong to . This set includes , , , ... (and others). This set is called the "humble numbers set" of . Note: We consider not to be a humble number.
Your task is, given the set , to find the -th humble number in the humble numbers set. It is guaranteed that the answer fits in a 32-bit signed integer.
Supplement: The humble numbers are ordered from small to large. Each humble number is a product of numbers from the prime set. The -th humble number is the -th smallest positive integer that can be formed by multiplying numbers from the prime set (including a prime itself).
Input Format
- The first line contains two integers, which are the size of the set and the given parameter .
- The second line contains distinct integers, where the -th integer denotes .
Output Format
Output a single integer, the answer.
4 19
2 3 5 7
27
Hint
- Constraints
For of the testdata, it is guaranteed that:
-
.
-
.
-
, and each is prime.
-
Notes
Problem translation from NOCOW.
USACO Training Section 3.1.
Translated by ChatGPT 5
京公网安备 11011102002149号