시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 8 MB (하단 참고) 0 0 0 0.000%

문제

Warning: Pay attention to the unusual memory limit.

You are given $k$ prime numbers $p_1, p_2 \dots, 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, \ldots \}$.

입력

The first line of the input contains two integers $k, N$ ($k \ge 1$, $1 \le N \le 10^{18}$) described above. The second line contains $k$ distinct prime numbers $p_1, \dots, p_k$ ($2 \le p_i \le 100$).

출력

You should output a single positive integer -- the largest number not exceeding $N$ whose prime factorization contains only prime numbers $p_1, p_2, \dots, p_k$.

예제 입력 1

3 30
2 3 7

예제 출력 1

28

제출할 수 있는 언어

C++14, Java, C11, C, C++, C++11, C++17, Java (OpenJDK), Java 11, C++2a, Kotlin (JVM), C (Clang), C++ (Clang), C++11 (Clang), C++14 (Clang), C11 (Clang), C++17 (Clang), C++2a (Clang)

메모리 제한 안내

아래 적혀있지 않은 메모리 제한은 언어 도움말에 적혀있는 기준을 따른다.

  • Java: 32MB
  • Java (OpenJDK): 32MB
  • Java 11: 32MB
  • Kotlin (JVM): 32MB