Logo
(追記) (追記ここまで)

18989번 - Product 다국어언어 제한

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

문제

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

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 5: Warsaw U Contest, XVIII Open Cup named after E.V. Pankratiev Onsite B번

Contest > Algorithmic Engagements > PA 2017 2-1번

제출할 수 있는 언어

C++17, Java 8, C11, C99, C++98, C++11, C++14, Java 8 (OpenJDK), Java 11, C++20, Kotlin (JVM), C99 (Clang), C++98 (Clang), C++11 (Clang), C++14 (Clang), C11 (Clang), C++17 (Clang), C++20 (Clang)

메모리 제한

  • Java 8: 32 MB
  • Java 8 (OpenJDK): 32 MB
  • Java 11: 32 MB
  • Kotlin (JVM): 32 MB
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /