3607.Minimum Modular

Time Limit: 1s Memory Limit: 256MB

You have been given n distinct integers a1,a2,...,an. You can remove at most k of them. Find the minimum modular m (m \gt 0), so that for every pair of the remaining integers (ai,aj), the following unequality holds: 3607_1.png.

Input Format(From the terminal/stdin)

The first line contains two integers n and k (1 \le n \le 5000,0 \le k \le 4), which we have mentioned above.

The second line contains n distinct integers a1,a2,...,an (0 \le ai \le 106).

Output Format(To the terminal/stdout)

Print a single positive integer - the minimum m.

Sample Input 1

Copy
7 0
0 2 3 6 7 12 18
 · \n
 · · · · ·  ·  \n

Sample Output 1

Copy
13
  \n

Sample Input 2

Copy
7 1
0 2 3 6 7 12 18
 · \n
 · · · · ·  ·  \n

Sample Output 2

Copy
7
 \n

Submit

请先 登录

© 2025 FAQs