Warning: Pay attention to the unusual memory limit.
You are given k prime numbers p_1,p_2…,p_k and an integer N. Your task is to find the largest integer not exceeding N whose prime factorization contains only these prime numbers.
For example, if the prime numbers are 2,3,7, the set of numbers whose factorization contains only these primes is 1,2,3,4,6,7,8,9,12,14,16,18,21,24,27,28,32,36,42,48,49,54,56,63,64,72,81,84,96,98,….