405016: GYM101741 F GCD
Memory Limit:0 MB
Time Limit:4 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
F. GCDtime limit per test4 secondsmemory limit per test512 mebibytesinputstandard inputoutputstandard output
You are given an array of integers a1, a2, ..., an.
Find the maximum possible greatest common divisor of all numbers from the array if you can erase no more than k elements () 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 ≤ n ≤ 105, ).
The second line contains n integers a1, a2, ..., an: the array a (1 ≤ ai ≤ 1018).
OutputPrint the maximum possible greatest common divisor of all elements of the array after erasing no more than k elements.
ExamplesInput4 1Output
6 15 35 14
1Input
4 2Output
6 15 35 14
7Input
3 1Output
897612484786617600 5828 16027
1457