#P15032. [UOI 2021 II Stage] 棋子

    ID: 16964 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>数学2021数论最大公约数 gcdUOI(乌克兰)

[UOI 2021 II Stage] 棋子

Problem Description

Recently, Cossack Beard found a chess piece and nn points lying on the same straight line. The initial coordinate of the chess piece is xx, and the coordinate of the ii-th point is aia_i.

Cossack Beard can first choose any positive integer kk. After that, he can change the coordinate of the chess piece any number of times by adding or subtracting kk. That is, he moves the chess piece a distance of kk to either side.

Cossack Beard wants to know: what is the maximum possible kk such that the chess piece can visit all the given nn points.

Input Format

The first line contains two integers nn and xx (2≤n≤105,−1018≤x≤10182 \le n \le 10^5, -10^{18} \le x \le 10^{18}), which represent the number of points on the line and the initial coordinate of the chess piece, respectively.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (−1018≤ai≤1018-10^{18} \le a_i \le 10^{18}), which are the coordinates of the points. It is guaranteed that all numbers in the array aa are pairwise distinct.

Output Format

Output one number, the maximum value of kk such that the chess piece can visit all nn given points.

3 2
10 -2 5
1
5 5
1 7 -1 11 15
2
6 0
0 -2019 84 -6 102 87
3

Hint

Translated by DeepSeek V3.

Translated by ChatGPT 5