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

19329번 - GCD 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB23936189.474%

문제

You are given an array of integers $a_1, a_2, \ldots, a_n$.

Find the maximum possible greatest common divisor of all numbers from the array if you can erase no more than $k$ elements ($k \le \frac{n}{2}$) from this array.

입력

The first line contains two integers: $n,ドル the number of elements in the array, and $k,ドル the maximum number of elements you can erase (2ドル \le n \le 10^5,ドル 0ドル \le k \le \frac{n}{2}$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$: the array $a$ (1ドル \le a_i \le 10^{18}$).

출력

Print the maximum possible greatest common divisor of all elements of the array after erasing no more than $k$ elements.

제한

예제 입력 1

4 1
6 15 35 14

예제 출력 1

1

예제 입력 2

4 2
6 15 35 14

예제 출력 2

7

예제 입력 3

3 1
897612484786617600 5828 16027

예제 출력 3

1457

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2018 > Day 8: Saratov SU Contest F번

Contest > Open Cup > 2017/2018 Season > Stage 13: Grand Prix of Saratov F번

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

출처

대학교 대회

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

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