Problem:


Score : 300 points

Problem Statement

There are N cities on a number line. The i-th city is located at coordinate x_i.

Your objective is to visit all these cities at least once.

In order to do so, you will first set a positive integer D.

Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:

Move 1: travel from coordinate y to coordinate y + D.

Move 2: travel from coordinate y to coordinate y - D.

Find the maximum value of D that enables you to visit all the cities.

Here, to visit a city is to travel to the coordinate where that city is located.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq X \leq 10^9

1 \leq x_i \leq 10^9

x_i are all different.

x_1, x_2, ..., x_N \neq X

Input

Input is given from Standard Input in the following format:

N X
x_1 x_2 ... x_N

Output

Print the maximum value of D that enables you to visit all the cities.

Sample Input 1

3 3
1 7 11

Sample Output 1

2

Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D.

Perform Move 2 to travel to coordinate 1.

Perform Move 1 to travel to coordinate 3.

Perform Move 1 to travel to coordinate 5.

Perform Move 1 to travel to coordinate 7.

Perform Move 1 to travel to coordinate 9.

Perform Move 1 to travel to coordinate 11.

Sample Input 2

3 81
33 105 57

Sample Output 2

24

Sample Input 3

1 1
1000000000

Sample Output 3

999999999



Sample input:
3 3
1 7 11


Sample output:
2

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def gcd_list(nums):
    return reduce(gcd, nums)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
diff = [abs(xi - X) for xi in x]
print(gcd_list(diff))

Submission status: Accepted

Solution code:
from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gcd_list(nums):
    return reduce(gcd, nums)

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

x_sorted = x
x_sorted.append(X)
x_sorted.sort()

diff = []
for i, xi in enumerate(x_sorted):
    if i == 0:
        continue
    else:
        diff.append(xi - x_sorted[i-1])

print(gcd_list(diff))

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n, x = map(int, input().split(' '))
lst = list(int(x) for x in input().split(' '))
ans = abs(x - lst[0])
for i in range(1, n):
    ans = gcd(ans, abs(x-lst[i]))
print(ans)

Submission status: Accepted

Solution code:
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

x=[]
N,X=list(map(int,input().split()))
x=list(map(int,input().split()))
    
ans=abs(X-x[0])
for i in range(N):
    ans=gcd(ans,abs(x[i]-X))

print(ans)

Submission status: Accepted

Solution code:
def gcd(x, y):
    while x > 0:
        x, y = y % x, x
    return y


nx = list(map(int, input().split()))
n = nx[0]
X = nx[1]
x = list(map(int, input().split()))
for i in range(n):
    x[i] = abs(x[i] - X)
ans = x[0]
for i in range(1, n):
    ans = gcd(ans, x[i])
print(ans)

Submission status: Accepted

Solution code:
#import math
import fractions

N,X=input().split()
N=int(N)
X=int(X)
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
de=[]#deference 差
for i in range( 0, len(x)-1 ):
    dei=x[i+1]-x[i]
    if(dei>0):
        de.append(dei)

#最大公約数だった
#その数を作る素因数をすべて抜き出し、
#一致するものをすべて抜き出せばできる
gcddd=de[0]#最大公約数
for i in range(1,len(de)):
    gcddd=fractions.gcd(gcddd,de[i])
print(gcddd)

Submission status: Accepted

Solution code:
import sys
import collections
import math
input=sys.stdin.readline


n,x=map(int,input().split())
l=list(map(int,input().split()))
l.append(x)
l.sort()
#print(l)
b=abs(l[0]-l[1])
li=[b]
lis=[]
#print(li)
for i in range(1,len(l)-1):
    a=abs(l[i]-l[i+1])
    li.append(a)
    b=min(a,b)
li=set(li)
for i in range(1,round(math.sqrt(b)+1)):
    if b%i==0:
        lis.append(i)
        lis.append(b//i)
lis.sort()
#rint(lis)
for i in lis:
    for j in li:
        if j%i!=0:
            break
    else:
        num=i
print(num)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, X = map(int, input().split())
    l = list(map(int, input().split()))

    if X not in l:
        l.append(X)
    l.sort()

    ans = None
    for i in range(len(l) - 1):
        diff = l[i + 1] - l[i]
        if ans is None:
            ans = diff
        else:
            ans = gcd(ans, diff)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def abc109_c():
    import numpy as np
    import functools
    import fractions
    n, x = map(int, input().split())
    x = np.abs(np.array(list(map(int, input().split()))) - x)
    gcd = functools.reduce(fractions.gcd, x)
    return gcd


print(abc109_c())

Submission status: Accepted

Solution code:
import fractions
from functools import reduce
import numpy as np

[n, x] = list(map(int, input().split()))
xn = list(map(int, input().split()))

xn += [x]
xn = np.abs(np.diff(xn))
print(reduce(fractions.gcd, xn))

Submission status: Accepted

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
N,X = map(int,input().split())
x = list(map(int,input().split()))
x = x+[X]
x.sort()
d = [x[i+1]-x[i] for i in range(N)]
D = d[0]
for i in range(1,N):
    D = gcd(D,d[i])
print(D)

Submission status: Accepted

Solution code:
# C
import numpy as np

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N,X = list(map(int,input().split()))
x = np.array(list(map(int,input().split())))
X_l = np.array([X] * N)
diff = np.unique(abs(x - X_l))

a = diff[0]
for i in range(1, len(diff)):
    b = diff[i]
    a = gcd(a, b)
    
print(a)

Submission status: Accepted

Solution code:

from functools import reduce
from fractions import gcd

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [abs(i-X) for i in x]

print(reduce(gcd, Y, 0))

Submission status: Accepted

Solution code:
from functools import reduce
# Python < 3.5
# from math import gcd
# Python >= 3.5
from fractions import gcd

N, X = map(int, input().split())
d = [abs(int(s) - X) for s in input().split()]

print(reduce(gcd, d, 0))

Submission status: Accepted

Solution code:
def yakusuu(i,m):
    _i=i
    while(i**2<=m):
        if(m%i==0):
            return i
        else:
            i+=1
    for j in range(_i-1,0,-1):
        if(m%j==0):
            break
    return m//j



def factoring(N,result):
    original_N=N
    tmp=2
    while(tmp<=N and (tmp-1)**2<=original_N):
        tmp=yakusuu(tmp,N)
        result.append(tmp)

        N//=tmp



N,start=map(int,input().split())
x=list(map(int,input().split()))
tmp_list=[]
factoring(abs(x[0]-start),tmp_list)
for i in range(N-1):
    now=abs(x[i]-x[i+1])
    new_list=[]
    for j in tmp_list:
        if(now%j==0):
            now//=j
            new_list.append(j)
    tmp_list=[new_list[i] for i in range(len(new_list))]

ans=1
for j in tmp_list:
    ans*=j
print(ans)

Submission status: Accepted

Solution code:
n, x = map(int, raw_input().split())
arr = map(int, raw_input().split())

def find_gcd(a, b):
    if b % a == 0:
        return a
    else:
        while b % a != 0:
            r = b % a
            b = a
            a = r
        return a

if n == 1:
    print abs(x - arr[0])
else:
    arr.append(x)
    arr.sort()
    dis_arr = []
    for i in range(n):
        dis_arr.append(abs(arr[i]-arr[i+1]))

    dis_arr.sort()
    for i in range(n-1):
        fir = dis_arr[i]
        sec = dis_arr[i+1]
        dis_arr[i+1] = find_gcd(fir, sec)
    print dis_arr[n-1]

Submission status: Accepted

Solution code:
import math

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

n, x = map(int,input().split())
li_x = list(map(int,input().split()))

for i in range(len(li_x)):
  if li_x[i] - x < 0:
    li_x[i] =x - li_x[i]
  else:
    li_x[i] = li_x[i] -x

if len(li_x)==1:
  print(li_x[0])

elif len(li_x)==2:
  print(gcd(li_x[0],li_x[1]))

else:
  g =gcd(li_x[0],li_x[1])
  k=2
  while k<len(li_x):
    g=gcd(g,li_x[k])
    k+=1
  print(g)

Submission status: Accepted

Solution code:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

N,X=[int(i) for i in input().split()]
a=input().split()
x=[]
for i in range(N):
    x.append(int(a[i]))
if(N==1):
    print(abs(x[0]-X))
    exit()
x=list(map(lambda y:abs(y-X) , x))
ans=gcd(x[0],x[1])
for i in range(2,N):
    ans=gcd(x[i],ans)
print(ans)

Submission status: Accepted

Solution code:
def gcd(a,b):
  n, m  = max(a, b), min(a, b)
  if n % m == 0:
    return m
  else:
    return gcd(m, n%m)

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[i] - X))
print(mod)

Submission status: Accepted

Solution code:
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Submission status: Accepted

Solution code:
N, X = map(int, input().split(' '))
xl = list(map(int, input().strip().split()))
for i in range(len(xl)):
    xl[i]=abs(xl[i]-X)
#print(xl)
ans=0
for i in range(len(xl)-1):
    while True:
        if xl[i]==0:
            break
            #ans = x[i]
        a=xl[i]
        xl[i]=xl[i+1]%xl[i]
        xl[i+1]=a
#    print(xl)

print(xl[len(xl)-1])

Submission status: Accepted

Solution code:
N, x = map(int, input().split())
X = list(map(lambda p: abs(int(p) - x), input().split()))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


q = X[0]
for i in range(1, N):
    q = gcd(q, X[i])

print(q)

Submission status: Accepted

Solution code:
n, X = map(int, input().split())
x = input().split()
x = [int(m) for m in x]

z = x
z.append(X)
z.sort()

w = []

for i in range(n + 1):
    if i != 0:
        w.append(z[i] - z[i - 1])

n1=len(w)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)


if n1==1:
    print(w[0])
else:
    element = gcd(w[0], w[1])
    if n1==2:print(element)
    else:
        for i in range(2,n1):
            element=gcd(element,w[i])
        print(element)

Submission status: Accepted

Solution code:
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

def LCM(m,n):
  if m>n:
    m,n=n,m
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
x=quick_sort(x)
D=abs(x[1]-x[0])
for i in range(N):
  D=LCM(D,abs(x[i+1]-x[i]))
print(D)

Submission status: Accepted

Solution code:
import collections
from fractions import gcd

inputs = []
N, X = map(int, input().split())
inputs = list(map(int, input().split()))
inputs.append(X)
inputs.sort()
D = []
for i in range(len(inputs)-1):    
    D.append(abs(inputs[i] - inputs[i+1]))

uniqueD = list(set(D))
#print(uniqueD)

result = uniqueD[0]
for i in range(len(uniqueD)):
    result = gcd(result, uniqueD[i])

print(result)

Submission status: Accepted

Solution code:
n,x = map(int,input().split())
li = list(map(int,input().split()))

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
b = li3[0]

def gcd(x,y):
    if x < y:
        x,y = y,x
    if y == 0:
        return x
    z = x % y
    return gcd(y,z)

for i in li3:
    b = gcd(b,i)

print(b)

Submission status: Accepted

Solution code:
import fractions
import functools

N,X = map(int,input().split())
x_list = list(map(int,input().split()))

x_list.append(X)
x_list.sort()

x_len = list()
for i in range(1,N+1):
    x_len.append(x_list[i]-x_list[i-1])

x_len.sort(reverse = True)

result = functools.reduce(fractions.gcd,x_len)

print(result)

Submission status: Accepted

Solution code:
import fractions

n,x = map(int,input().split())
nums = list(map(int,input().split()))

min_n = abs(x-nums[0])
for i in range(1,n):
  min_n = fractions.gcd(min_n,abs(x-nums[i]))

print(min_n)

Submission status: Accepted

Solution code:
# abc109_c

from functools import reduce


def mcd(x, y):
    rest = x % y
    if rest == 0:
        return y
    else:
        return mcd(y, rest)


def solve(seq):
    if len(seq) == 2:
        return abs(seq[0] - seq[1])

    satisfy = []  # find distances to satisfy
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))

    return reduce(mcd, sorted(satisfy, reverse=True))


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Submission status: Accepted

Solution code:
# abc109_c

from functools import reduce


def mcd(x, y):
    if x > y:
        big = x
        small = y
    else:
        big = y
        small = x
    while True:
        rest = big % small
        if rest == 0:
            return small
        else:
            big = small
            small = rest


def solve(seq):
    satisfy = []  # find distances to satisfy
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))

    if len(satisfy) == 1:
        return satisfy[0]

    return reduce(mcd, satisfy)


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Submission status: Accepted

Solution code:
# abc109_c


def mcd(x, y):
    if x > y:
        big = x
        small = y
    else:
        big = y
        small = x
    while True:
        rest = big % small
        if rest == 0:
            return small
        else:
            big = small
            small = rest


def solve(seq):
    satisfy = []  # find distances to satisfy
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))
    # print(satisfy)

    if len(satisfy) == 1:
        return satisfy[0]

    mcds = []
    for i in range(len(satisfy) - 1):
        mcds.append(mcd(satisfy[i], satisfy[i + 1]))
    # print(sol)

    return min(mcds)


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce
 
N, X = map(int, input().split())
 
L = []

def minus_X(n):
  return abs(n - X)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

L = list(map(int, input().split()))

L2 = map(minus_X, L)
 
print(gcd_list(L2))

Submission status: Accepted

Solution code:
def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a

N, X = map(int, input().split())
a = [abs(int(i)-X) for i in input().split()]


if N == 1:
    print(a[0])
else:
    ans = gcd(a[0], a[1])
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)

Submission status: Accepted

Solution code:
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

ret = abs(X - x[0])
for i in range(1, N):
    ret = fractions.gcd(ret, abs(X - x[i]))

print(ret)

Submission status: Accepted

Solution code:
from functools import reduce

N, X = map(int, input().split())

def _calc(a,b):
    while b:
        a, b = b, a % b
    return a

def calc(n_list):
    return reduce(_calc, n_list)

c = list(map(int, input().split()))
c = [ abs(x-X) for x in c ]

print(calc(c))

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))
d = [abs(xi - X) for xi in x]
print(reduce(gcd, d))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X=map(int,input().split( ))
x=list(map(int,input().split( )))
def minus_d(x):
	x = abs(x-X)
	return x

def percent_d(x):
	x = x % d
	return x

dis = list(map(minus_d, x))
ans = gcd_list(dis)
print(ans)

Submission status: Accepted

Solution code:

import math
from functools import reduce
a,b=input().split()
l=sorted([abs(int(x)-int(b)) for x in input().split()])

def gcd(a,b):
    if a < b:
        a,b = b,a
    if  b==0:
        return a
    c = a % b
    return gcd(b,c)
while len(l)!=1:
    l.append(gcd(l.pop(0),l.pop(-1)))
print(sum(l))

Submission status: Accepted

Solution code:
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    while q != 0:
        p, q = q, p % q
    return p

y = xs[0]
for i in range(N):
    if xs[i] % y != 0:
        y = gcd(y, xs[i])

print(y)

Submission status: Accepted

Solution code:
from fractions import gcd
import numpy as np
n, x0 = map(int, input().split())
x = np.abs(np.array(list(map(int, input().split()))) - x0)
xx = x[0]
for i in range(1, n):
    xx = gcd(xx, x[i])
print(xx)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd


def main():
    n, x = map(int, input().split())
    xs = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        xs[i] -= x
        if xs[i] < 0:
            xs[i] *= -1
        ans = gcd(ans, xs[i])

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
import fractions
from functools import reduce
import sys

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,z=map(int,input().split())
y=list(map(int,input().split()))

if(n==1):
    print(abs(y[0]-z))
    sys.exit()
y=np.array(y)
y=y-z
a=np.min(abs(y))
t=[]
for i in range(1,n):
    t.append(abs(y[i]-y[i-1]))

print(fractions.gcd(a,gcd_list(t)))

Submission status: Accepted

Solution code:
N, X = map(int, input().split())

num = [int(i) for i in input().split()]

distance = [0] * N
remain = []

# １つしか訪れないとき
if(N ==1):
    distance[0] = abs(X - num[0])
    print(distance[0])
    exit()

#2つ以上訪れるとき
for i in range(N):
    # 各距離を測る
    distance[i] = abs(X - num[i])

    if(i == 0):
        continue

    #各距離の最大公約数を求める
    a = distance[i-1]
    b = distance[i]
    if(distance[i-1] < distance[i]):
        temp = a
        a = b
        b = temp

    r = a % b
    while(r != 0):
        a = b
        b = r
        r = a % b

    remain.append(b)

print(min(remain))

Submission status: Accepted

Solution code:
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
d=abs(x[0]-X)
if N==1:
    print(d)
    exit()
for i in range(1,len(x)):
    d=fractions.gcd(d,abs(x[i]-X))
print(d)

Submission status: Accepted

Solution code:
import fractions

n, a = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(t-a) for t in x]

if n == 1:
  print(x[0])
  exit()
  
d = x[0]
for t in x[1:n]:
  d = fractions.gcd(d,t)
print(d)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)


from functools import reduce


def main():
    N, X = get_ints()
    x = get_ints()
    x = [abs(_ - X) for _ in x]

    print(reduce(gcd, x))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(x1,x2):
    while x2 != 0:
        x1,x2 = x2, x1%x2
    return x1

for i in range(len(x)):
    x[i] = abs(x[i]-X)

ans = x[0]
for i in range(1,len(x)):
    ans = gcd(ans,x[i])
print(ans)

Submission status: Accepted

Solution code:
# import math


def gcd(a, b):
    a = abs(a)
    b = abs(b)
    if b > a:
        return gcd(b, a)
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

# print(make_divisor_list(24))


N, X = [int(x) for x in input().split()]
xlist = [int(x) for x in input().split()]

# print(xlist)

shiftedX = [x - X for x in xlist]

# print(shiftedX)

maxDivisor = shiftedX[0]
for n in shiftedX:
    maxDivisor = gcd(maxDivisor, n)

print(maxDivisor)

Submission status: Accepted

Solution code:
n,x = map(int,input().split())
s = list(map(int,input().split()))

u = []

for i in range(n):
	u.append(abs(s[i]-x))
import math

m = u[0]


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()

x = 0

for i in range(len(s)):
	for j in range(n):
		if u[j]%s[i]!=0:
			break
	else:
		x = max(x,s[i])
print(x)

Submission status: Accepted

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
x=[abs(i-X) for i in x]

def gcm(a,b):
    if a<b:a,b=b,a
    c=a%b
    while c>0:
        a,b=b,c
        c=a%b
    return b

D=x[0]
for i in range(N):
       D=gcm(D,x[i])
print(D)

Submission status: Accepted

Solution code:
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(y)

Submission status: Accepted

Solution code:
def gcd(A, B):
    if A%B == 0:
        return B
    else:
        return gcd(B, A%B)
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
if N == 1:
    print(x[0])
    exit()
gcd_x = []
for i in range(N-1):
    gcd_x.append(gcd(x[i], x[i+1]))
print(min(gcd_x))

Submission status: Accepted

Solution code:
import fractions
import functools

n, x = map(int, input().split())

xi = list(map(int, input().split()))

l = []
for i in range(n):
    l.append(abs(xi[i] - x))

ans = functools.reduce(fractions.gcd, l)

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

N, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

A.append(X)
sortedA = sorted(A)
B = [sortedA[i+1] - sortedA[i] for i in range(len(sortedA)-1)]

ans = reduce(gcd, B)
print(ans)

Submission status: Accepted

Solution code:
#abc110 C 最大公約数
N, X = map(int, input().split())
x= list(map(int, input().split()))
distance = [ abs(x[i]-X) for i in range(N)]

def gcd( x , y ):
    while y != 0:
        x,y = y, x%y
    return x

def GCD(lis):
    g = lis[0]
    for i in range(1,len(lis)):
        g = gcd( g , lis[i] )
    return g

maxD = GCD(distance)
print(maxD)

Submission status: Accepted

Solution code:
#C - Skip
import sys

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

residual = [abs(x - X) for x in x_list]

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b, a%b)
        
max_ = 0
for i in range(len(residual)):
    if(N==1):
        print(residual[0])
        break
    
    if(i == 0):
        max_ = gcd(residual[i], residual[i+1])
    elif(i == N-1):
        print(max_)
    else:
        max_ = gcd(residual[i], max_)

Submission status: Accepted

Solution code:
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)

Submission status: Accepted

Solution code:
def gcd(a, b):
    if b==0:
        return a
    else:
        return gcd(b, a % b)

N, X = map(int, input().split())
x = list(map(int, input().split()))

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = gcd(ans, b)
print(ans)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Submission status: Accepted

Solution code:
from functools import *
N, X = list(map(int, input().split(" ")))
xs = list(map(int, input().split(" ")))
xs = list(map(lambda x: X-x if X>x else x-X, xs))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b) 
r = reduce(gcd, xs)
print(r)

Submission status: Accepted

Solution code:
N,X = map(int,input().split())
list = [int(x) for x in input().split()]
list_dist = sorted([abs(x - X) for x in list])

def gcd(a, b):
    if a < b:
        a , b = b , a
    while b:
        a, b = b, a % b
    return a

ans = list_dist[0]

for x in list_dist[1:]:
    ans = gcd(ans,x)

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
N, X = list(map(int, input().split()))
lst = list(map(lambda x: abs(int(x)-X), input().split()))
print(reduce(gcd, lst))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

a = input()
N = int(a.split(" ")[0])
X = int(a.split(" ")[1])

place = list(map(int,input().split(" ")))

b = []
place.append(X)
place.sort()
for i in range(len(place)-1):
    b.append(int(place[i+1]) - int(place[i]))
print(gcd_list(b))

Submission status: Accepted

Solution code:
from fractions import gcd 
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)

Submission status: Accepted

Solution code:
# coding:utf-8

from fractions import gcd
from functools import reduce

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

d = reduce(gcd, dist_list)

print(d)

Submission status: Accepted

Solution code:
# coding:utf-8

from fractions import gcd 

n, y = map(int, input().split())

dist_list = [abs(x-y) for x in map(int, input().split())]

if n == 1:
    d = dist_list[0]
else:
    d = gcd(dist_list[1], dist_list[0])
    for i in range(n-2):
        d = gcd(d, dist_list[i+1])

print(d)

Submission status: Accepted

Solution code:
def gcd(x,y):
    if x < y:
        (x,y) = (y,x)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
gcd1 = list_dist[0]
for i in range(1,n):
    gcd1 = gcd(gcd1, list_dist[i])
print(gcd1)

Submission status: Accepted

Solution code:
#リストの中身を全て足したり、書けたりしてくれる関数
#gcdは最大公約数を求める関数。こんな便利なものがあったのか！
from functools import reduce
from fractions import gcd


N,X = map(int, input().split())
x = list(map(int, input().split()))

"""
出発地点Xは決まっている
一番近いところと、一番遠いところを考えたとき、最大公約数を求めればいいのでは？
これが全部の公約数になってないといけないかな？

まず、一番近いところを決める
この約数を求める
一番大きいやつに決定する
"""

#abs()は絶対値を返す関数

x.append(X)

sa = [abs(x[i+1]-x[i]) for i in range(N)]
#それぞれの値の差（距離）を取ってあるので、全ての数値の最大公約数を求める
answer = reduce(gcd, sa)

print(answer)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
sa = [abs(x[i+1]-x[i]) for i in range(n)]
d = reduce(gcd,sa)
print(d)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
sa = [abs(x[i+1]-x[i]) for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
x.sort()
sa = [x[i+1]-x[i] for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))

def func(x,n):
    x.sort()
    y = [abs(x[i+1]-x[i]) for i in range(n-1)]
    kotae = reduce(lambda a,b:gcd(a,b),y)
    print(kotae)

if x_ in x:
    func(x,n)
else:
    x.append(x_)
    func(x,n+1)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

N, X = map(int, input().split())
x = map(int, input().split())
distance = list(map(lambda i: abs(X - i), x))

gratest_common_facter = reduce(fractions.gcd, distance)
print(gratest_common_facter)

Submission status: Accepted

Solution code:
#! /usr/bin/python
#from math import gcd
from fractions import gcd
from functools import reduce
#N, X = 3, 3
#CITY = [1, 7, 11]
#
#N, X = 3, 81
#CITY = [33, 105, 57]

N,X= map(int,input().split())
CITY = list(map(int,input().split()))

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))

Submission status: Accepted

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
absx=[]
for i in range(len(x)):
    absx.append(abs(x[i]-X))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)
print(gcd_list(absx))

Submission status: Accepted

Solution code:
n, x = map(int, input().split())
xarr =list(map(int, input().split()))

xarr.append(x)

xarr.sort()

arr2 = []
for i in range(len(xarr)-1):
	arr2.append(xarr[i+1]-xarr[i])

def gcb(a, b):
	while b:
		a, b = b, a % b
	return a

gc = 0

if len(arr2) > 1:
	gc = gcb(arr2[0],arr2[1])
	for y in range(len(arr2)-1):
		gc = gcb(gc,arr2[y+1])
else:
	gc = arr2[0]
	
print(gc)

Submission status: Accepted

Solution code:
N, X = map(int, input().split())
x = [int(i) for i in input().split()]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in range(0,N):
    x[i] = x[i] - X

D = x[0]

for i in range(0,N):
    D = gcd(D,x[i])

D = abs(D)
print(D)

Submission status: Accepted

Solution code:
# from math import gcd # ダメ
def gcd(a,b): 
    while b!=0:
        a,b=b,a%b
    return a

n, X = map(int, input().split())
x = list(map(int, input().split()))

ans = abs(x[0]-X)
for xi in x:
    ans = gcd(ans, abs(xi-X))
    
print(ans)