아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Product

시간 제한2초메모리 제한8 MB

요약
100 이하의 서로 다른 소수 k개와 10^18 이하의 N이 주어질 때, 소인수가 모두 그 집합에 속하면서 N을 넘지 않는 가장 큰 수를 찾는다.
난이도

보통10점 중 7점

유형
백트래킹, 수학, 정수론
정답자
아직 제출이 없습니다

문제

Warning: Pay attention to the unusual memory limit.

You are given kk prime numbers p_1,p_2…,p_kp\_1, p\_2 \dots, p\_k and an integer NN. Your task is to find the largest integer not exceeding NN whose prime factorization contains only these prime numbers.

For example, if the prime numbers are 2,3,72, 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,…\\{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,Nk, N (k≥1k \ge 1, 1≤N≤10181 \le N \le 10^{18}) described above. The second line contains kk distinct prime numbers p_1,…,p_kp\_1, \dots, p\_k (2≤p_i≤1002 \le p\_i \le 100).

출력

You should output a single positive integer -- the largest number not exceeding NN whose prime factorization contains only prime numbers p_1,p_2,…,p_kp\_1, p\_2, \dots, p\_k.

예제1

  1. 예제 1

    입력
    3 30
    2 3 7
    
    예상 출력
    28