PROBLEM STATEMENT
Any positive integer can be written as a product of prime factors. A prime
number, of course, is one whose only factors are 1 and itself. 1 is not a
prime number.
For example: 36 = 2*2*3*3.
Similarly, a number can be approximated by a larger number whose prime
factorization contains only certain numbers.
Example: If we have prime numbers 2 and 5 to work with, 18 can best be
approximated by 2*2*5 = 20.
Similarly, if we have prime numbers 2, 3, and 5 to work with, 28 can best be
approximated by 2*3*5 = 30.
DEFINITION
Class name: Factors
Method name: smallest
Parameters: int[], int
Returns: int
The method signature is (make sure it is declared public):
int smallest(int[] factors, int match);
Given factors, which contains a list of prime numbers, and an integer match,
determine what the smallest positive integer, whose prime factorization
contains only members of factors, which is larger than or equal to match.
TopCoder will enforce the following restrictions:
* factors will contain between 1 and 5 numbers, inclusive
* each element of factors will be a prime number between 2 and 29, inclusive
* each element of factors will be unique
* match will be between 2 and 100000, inclusive
Example:
smallest({3,7}, 24)
3*3 = 9 < 24, so that doesn't work
3*7 = 21 < 24
7*7 = 49 > 24, so that works, but
3*3*3 = 27 > 24, so 3*3*3 = 27 is the smallest such number.
smallest({2,5}, 11) returns 16
smallest({2,3}, 8) returns 8