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: Wrong Answer

Solution code:
import numpy as np
def div(N):
    sq = int(np.sqrt(N))
    divs = [1]
    for i in range(2,sq+1):
        if  N%i == 0:
            divs.append(i)
    divs.append(N)
    return divs


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

X = sorted(X)
npX = np.array(X)

X_del = []
for i in range(N-1):
    X_del.append(X[i+1] - X[i])

if len(X_del) > 0:
    min_del = min(X_del)
else:
    print(X[0] - S)
    exit()
ans = 1

np_X_del = np.array(X_del)
divs = div(min_del)


for div in divs[::-1]:
    sa = abs(np_X_del - div)
    if np.min(sa) >= 0:
        waru = np_X_del % div

        if np.max(waru) == 0:

            ch = abs(npX - S)
            ch = ch%div
            if 0 in ch:
                print(div)
                exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
def div(N):
    sq = int(np.sqrt(N))
    divs = [1]
    for i in range(2,sq+1):
        if  N%i == 0:
            divs.append(i)
    divs.append(N)
    return divs


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

X.append(S)
X = sorted(X)

X_del = []
for i in range(N):
    X_del.append(X[i+1] - X[i])

min_del = min(X_del)
ans = 1

np_X_del = np.array(X_del)
divs = div(min_del)

for div in divs[::-1]:
    sa = abs(np_X_del - div)
    if np.min(sa) >= 0:
        waru = np_X_del % div

        if np.max(waru) == 0:
            print(div)
            exit()

Submission status: Wrong Answer

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

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
D = xs[1] - xs[0]
for i in range(N):
    d = xs[i+1] - xs[i]
    if d < D:
        D = gcd(d, D)
    if D == 1:
        print(1)
        break
else:
    print(D)

Submission status: Wrong Answer

Solution code:
n, place = [int(x) for x in input().split(' ')]
city_address = sorted([abs(int(x) - place) for x in input().split(' ')], reverse=True)
print(city_address)
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
 
answer = city_address[0]
for address in city_address:
	answer = gcd(answer, address)
 
print(answer)

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==c:
                    return i
            if i > 10:
                i -= i//2
            else: 
                i -=1
        else:
            i -=1            
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==c:
                    return i
                if i == 1:
                    return 1
            i -= i//2
        else:
            i -=1
 
 
 
 
                
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==c:
                    return i
            i -= i//2-1
        else:
            i -=1
 
 
 
 
                
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==c:
                    return i
            i -= i//2
        else:
            i -=1
 
 
 
 
                
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==len(b):
                    return i
            i -= i//2
        else:
            i -=1
 
 
 
 
                
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

def dec():

    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i !=0:
                    break
                k +=1
                if k == d:
                    return i 
        i -=1       
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

def dec():

    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i !=0:
                    break
                
                return i 
        i -=1       
print(dec())

Submission status: Wrong Answer

Solution code:
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

def dec():

    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i !=0:
                    break
                else:
                    return i 
        i -=1       
print(dec())

Submission status: Wrong Answer

Solution code:



c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

def dec():

    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i !=0:
                    return 1
                else:
                    return i 
        i -=1       
print(dec())

Submission status: Wrong Answer

Solution code:

c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

lo = []

while i > 0:
    if m% i == 0: 
        lo.append(i)
    i -=1

    
def dec():
    k = 0
    for i in lo:
        for j in b:
            if j%i ==0:
                k+=1
        if k==len(b):
            return i
                
print(dec())

Submission status: Wrong Answer

Solution code:
def euclid(a,b):
    if b == 0:
        return a 
    else:
        return euclid(b,a%b)
n,x = map(int,input().split())
cit = list(map(lambda i:int(i)-x,input().split()))

d = cit[0]
#cit-xの最大公約数
for i in range(n-1):
    d = euclid(d,cit[i+1])
    if d == 1:
        break
print(d)

Submission status: Wrong Answer

Solution code:
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
  ans = l[0]
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l = list(set(l))
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
  ans = l[0]
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
  ans = l[0]
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = list(map(int, input().split())) # 整数
list_temp = []
list_temp.append(list(map(int, input().split())))
list = list_temp[0]

list_dev = []

#公約数の関数作成
def devisor(X,N):
    list_div = []
    if N == 1:
        list_div.append(X)
        return list_div
    elif N >= 2:
        for i in range(1,X+1):
            if X % i == 0:
                list_div.append(i)
        return list_div

#xiとXの絶対値をとって、各絶対値の最大公約数を算出
for i in list:
    abs_temp = abs(i - X)
    list_dev += devisor(abs_temp,N)

#Nが2以上の場合は最大公約数を求める
if N == 1:
    print(list_dev[0])
elif N >= 2:
    l_dupli = [i for i in set(list_dev) if list_dev.count(i) > 2]
    print(l_dupli[-1])

Submission status: Wrong Answer

Solution code:
import functools as ft

N,X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]


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

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

def minusX(a):
    return abs(a-X)


Xi = map(minusX,Xi)

def main():
    output = minusX(gcd_list(Xi))
    print(output)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import permutations

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

xi = [X] + [x for x in xi]

dist = []
for a, b in permutations(xi, 2):
    dist.append(abs(a - b))
dist = set(dist)

print(min(dist))

Submission status: Wrong Answer

Solution code:
from functools import reduce

def gcd(a, b):

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

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

N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]

def minusX(a):
    return a-X

Xi = map(minusX, Xi)

d = gcd_list(Xi)
print (d)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

N, X = tuple(map(int, input().split(" ")))
Xs = list(map(int, input().split(" ")))
r = gcd_list(Xs)
print(r)

Submission status: Wrong Answer

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

    return a

N,X = map(int,input().split())
cities = [int(x) - X for x in input().split()]

#print(cities)

if N == 1:
    print(abs(cities[0] - X))
else:
    ans = gcd(cities[0],cities[1])

    for i in range(1,len(cities) - 1):
        ans = gcd(ans, cities[i+1])
        #print(ans)

    print(abs(ans))

Submission status: Wrong Answer

Solution code:
import fractions
n, fx = map(int, input().split())
x = list(map(int, input().split()))
x.append(fx)
x.sort()

ans = x[1]-x[0]
for i in range(2, len(x)):
  v = x[i]-x[i-1]
  ans = max(ans, fractions.gcd(ans, v))

print(ans)

Submission status: Wrong Answer

Solution code:
arg1 = input().split()
arg2 = input().split()
N = int(arg1[0])
X = int(arg1[1])

minimum = 10 ** 9
for i in range(N):
    minimum = min(abs(int(arg2[i]) - X), minimum)

print(minimum)

Submission status: Wrong Answer

Solution code:
N, X = map(int,input().split())
x = list(input().split())
x = sorted([int(i) for i in x])
diff = [10**10]
res = 10**10
for i in x:
    if i !=x[0]:
        diff.append(i-old)
    res = min(abs(X-i),res)
    old = i
res = min(min(diff),res)
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = abs(X-next(x))
for i in x:
    r = fractions.gcd(r, i-X)
print(r)

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = X-next(x)
for i in x:
    r = fractions.gcd(r, X-i)
print(r)

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = next(x)-X
for i in x:
    r = fractions.gcd(r, i-X)
print(r)

Submission status: Wrong Answer

Solution code:
import fractions

n,x=map(int,input().split())
citys=list(map(int, input().split()))
mod_citys=citys
for i in range(len(mod_citys)):
    mod_citys[i]-=x
    if(mod_citys[i]<0):
        mod_citys[i] *= -1
if(len(mod_citys)==1):
    print(mod_citys[0])
elif(len(mod_citys)==2):
    print(fractions.gcd(mod_citys[0],mod_citys[1]))
else:
    mod_citys = sorted(mod_citys, reverse=False)
    print(fractions.gcd(mod_citys[0], mod_citys[1]))

Submission status: Wrong Answer

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

xs = [ int(x) for x in input().split() ] 

left =  list(reversed([abs(x-X) for x in list(filter(lambda x:x <= X, xs))] + [0] ))
right = [x-X for x in ([X] + [x for x in list(filter(lambda x:x >= X, xs))]) ]
#print(left)
#print(right)

stocks = set()
for d in range(1,len(right)):
  stocks.add( right[d] - right[d-1] )
for d in range(1,len(left)):
  stocks.add( left[d] - left[d-1] )

print(min(stocks))

Submission status: Wrong Answer

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




x.append(X)
x.sort()

i = 0
min_num = 10**9

while i < len(x)-1:
    dif = x[i+1] - x[i]
   

    if dif < min_num:
        min_num = dif
        

    i += 1


print(min_num)

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
f = [l]
if l < 999999999:
    for i in range(1, l):
        if l % i == 0:
            f.append(i)
for i in range(len(f), 0, -1):
    d = True
    for item in c:
        if item % f[i-1] != 0:
            d = False
    if d:
        print(f[i-1])
        break

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
f = [l]
if l < 100000000:
    for i in range(1, l):
        if l % i == 0:
            f.append(i)
for i in range(len(f), 0, -1):
    d = True
    for item in c:
        if item % f[i-1] != 0:
            d = False
    if d:
        print(f[i-1])
        break

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
f = [l]
if n > 1:
    for i in range(1, l):
        if l % i == 0:
            f.append(i)
for i in range(len(f), 0, -1):
    d = True
    for item in c:
        if item % f[i-1] != 0:
            d = False
    if d:
        print(f[i-1])
        break

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
f = set()
for i in range(1, l+1):
    if l % i == 0:
        f.add(i)
for i in range(len(f), 0, -1):
    d = True
    for item in c:
        if item % i != 0:
            d = False
    if d:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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


N, X = (int(i) for i in input().split())
A = [int(i) for i in input().split()]


def aho(x):
  return x - X


B = list(map(aho, A))

C = gcd_list(B)

print(C)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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


N, X = (int(i) for i in input().split())
A = [int(i) for i in input().split()]


def aho(x):
  return x - N


B = list(map(aho, A))

C = gcd_list(B)

print(C)

Submission status: Wrong Answer

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

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


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


a = [i - x for i in a]
from functools import reduce
print(reduce(gcd, a))

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    for diff in diffs:
        if diff % min(diffs) != 0:
            print('1')
            return

    print(min(diffs))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))
    
    print(min(diffs))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
def main():
      global X
      global x
      print(answer(pre(X,x)))
def pre(a,b):
      b = [i-a for i in b]
      return b
def answer(k):
      Min = min([abs(i) for i in k])
      flag = False
      for i in range(1,Min+1):
            if flag == True:
                  return ans
            flag = True
            if Min%i==0:
                  ans = Min//i
                  for j in k:
                        if j%ans!=0:
                              flag = False
            else:
                  flag = False
main()

Submission status: Wrong Answer

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

if(N==1):
    print(abs(N-x[0]))
else:
    dx=[]
    for i in range(N-1):
        dx.append(abs(x[i]-x[i+1]))
    
    de=[]
    for i in range(1,min(dx)+1):
        for j in dx:
            if(j%i!=0):
                break
        else:
            de.append(i)
        
    for i in reversed(de):
        if(abs(X-x[0])%i==0):
            print(i)
            break

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    X.append(NX[1])
    # if len(X) == 1:
    #     print(abs(X[0]-NX[1]))
    #     sys.exit(0)

    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = min(diff)
    while any(np.array(diff)%D):
        i = D / 2
        while D % i != 0:
            i -= 1
        D = i
    print(D)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X[0]-NX[1]))
        sys.exit(0)

    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = min(diff)
    while any(np.array(diff)%D):
        D -= 1
    print(D)

Submission status: Wrong Answer

Solution code:
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

Submission status: Wrong Answer

Solution code:
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=min((m,xlist[i]))
print(m)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
while xlist==[0]*n:
   for i in range(n):
        xlist[i]-=x
        xlist[i]=abs[xlist[i]]
        xlist[i]%=m
        if xlist[i]>0:
            m=min((m,xlist[i]))
print(m)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
while xlist==[0]*n:
   for i in range(n):
        xlist[i]-=x
        xlist[i]=abs[xlist[i]]
        xlist[i]%=m
        m=min((m,xlist[i]))
print(m)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda x:abs(x))
m=xlist[0]-x
while xlist==[0]*n:
   for i in range(n):
        xlist[i]-=x
        xlist[i]%=m
        m=min((m,xlist[i]))
print(m)

Submission status: Wrong Answer

Solution code:
# 正の数を受け取るように定義
def gcd(a,b):
    while b > 1:
        a, b = b, a % b
    return a

N, X = map(int,input().split())
k = [abs(int(x) - X) for x in input().split()] # リスト内包表記で入力の受け取り
a = k[0]
for i in range(1,N):
    a = gcd(a,k[i])
print(str(a))

Submission status: Wrong Answer

Solution code:
# 正の数を受け取るように定義
def gcd(a,b):
    while b > 1:
        a, b = b, a % b
    return a

N, X = map(int,input().split())
k = [abs(int(x) - X) for x in input().split()] # リスト内包表記で入力の受け取り
a = k[0]
if N == 1:
    print(str(a))
else:
    for i in range(1,N):
        a = gcd(a,k[i])
    print(str(a))

Submission status: Wrong Answer

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

N, X = map(int, input().split())
x = [int(_) for _ in input().split(' ')]

dist = [abs(i - X) for i in x]

ans = dist[0]

for i in range(N):
    ans = gcd(ans, dist[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce

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

    return a

def multi_gcd(*numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split(' '))
city = np.array(list(map(int, input().split(' '))))

city -= X
print(multi_gcd(*city))

Submission status: Wrong Answer

Solution code:
def sub(a, b):
    if a >= b:
        s = a-b
    else:
        s = b-a
    return s
def gcd(a , b):
    num1 = int(a)
    num2 = int(b)
    i = sub(num1, num2)
    while i > 0:
        num1 = num2
        num2 = i
        i = sub(num1, num2)
    return num2


n_str,x_str = input().split()
n = int(n_str)
x = int(x_str)

point_list = []
point_str_list = input().split()
for i in point_str_list:
    i = int(i)
    point_list.append(i)

point_list.sort()

def_list = []
for i in range(n-1):
    defference = point_list[i+1] - point_list[i]
    def_list.append(defference)

if n == 1:
    def_list.append(abs(n-point_list[0]))


a = def_list[0]
for i in def_list:
    a = gcd(a,i)

print(a)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n, x = map(int, input().split())
y = [int(v) - x for v in input().split()]
y.append(0)
g = reduce(gcd, y)
print(g)

Submission status: Wrong Answer

Solution code:
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

"""
for i in range(min_distance,0,-1):
    Can_go_list=list(map(lambda z: 1 if z % i == 0 else 0,first_distance))

    if 0 not in Can_go_list:
        ans = i
        print(ans)
        break
"""

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

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

Submission status: Wrong Answer

Solution code:
from functools import reduce

Submission status: Wrong Answer

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

def Gcd(a, b):
	return Gcd(b, a % b) if b != 0 else a
N,X = map(int,input().rstrip().split())
x = list(map(int,input().rstrip().split()))
x.append(X)
x.sort()
mini = x[1] - x[0]
maxi = x[1] - x[0]
for i in range(len(x)-1):
	if mini > x[i+1] - x[i]:
		mini =  x[i+1] - x[i]
	if maxi < x[i+1] - x[i]:
		maxi =  x[i+1] - x[i]
print(Gcd(mini,maxi))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
ans = 10**9
for i in range(N):
    d = x[i+1] - x[i]
    if d < ans:
        if ans % d:
            ans = 1
            break
        ans = d
    
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
n, start = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(start)
x_list.sort()


current_gcd = x_list[1] - x_list[0]
for i in range(1, n-1):
    gap = x_list[i+1] - x_list[i]
    current_gcd = fractions.gcd(current_gcd, gap)

print(current_gcd)

Submission status: Wrong Answer

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

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

mini = x[1] - x[0]
mini2 = x[-1] - x[-2] 
for i in range(len(x)-1):
	if mini > x[i+1] - x[i]:
		mini =  x[i+1] - x[i]
print(Gcd(mini,mini2))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
ans = float('inf')
for i in range(N):
    ans = min(ans, x[i+1] - x[i])
print(max(1,ans))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
ans = float('inf')
for i in range(N):
    ans = min(ans, x[i+1] - x[i])
print(min(1,ans))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
ans = float('inf')
for i in range(N):
    ans = min(ans, x[i+1] - x[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().rstrip().split())
x = list(map(int,input().rstrip().split()))
x.append(X)
x.sort()
mini = x[1] - x[0]
for i in range(len(x)-1):
	if mini > x[i+1] - x[i]:
		mini =  x[i+1] - x[i]
print(mini)

Submission status: Wrong Answer

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

x_list.sort()
def gcd(a, b):
    if a >= b:
        return a if b == 0 else gcd(b, a % b)
    else:
        return gcd(b, a)

if N == 1:
    print(x_list[0]-X)
    exit()


D = abs(x_list[0]-X)
for i in range(1, N):
    D = gcd(D, abs(x_list[i-1]-x_list[i]))

print(D)

Submission status: Wrong Answer

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


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

if N == 1:
    print(x_list[0]-X)
    exit()


D = abs(x_list[0]-X)
for i in range(1, N):
    D = gcd(D, abs(x_list[i-1]-x_list[i]))

print(D)

Submission status: Wrong Answer

Solution code:
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

# for i in range(len(dic) - 1):
#     ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

Submission status: Wrong Answer

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

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

def check(n):
    return abs(n - x)

dist = list(map(check, city))
min_dist = min(dist)
for w in dist:
    if w % min_dist != 0:
        min_dist = 1

if n < 2:
    print(min_dist)
    exit()

dists = []
prev = 0

city.sort()
for pos in city:
    if not prev == 0:
        dists.append(abs(prev - pos))
    prev = pos

new_min = min(dists)

if min_dist % new_min == 0:
    print(new_min)
elif new_min % min_dist == 0:
    print(min_dist)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(1, len(x)):
    tmp = x[i] - x[i - 1]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

# for i in range(1, len(dic)):
#     ans = min(ans, math.gcd(dic[i], dic[i - 1]))
#
# print(ans)

Submission status: Wrong Answer

Solution code:
N,X = map(int,input().split())
L = list(map(int,input().split()))
counter = 0
L.append(X)
L = sorted(L)
D = []
for i in range(len(L)) :
    d = L[i]-L[i-1]
    if i != 0 :
        D.append(d)

D = sorted(D)
qq = min(D)
for j in range(len(D)-1) :
    if D[j+1] % qq != 0 :
        counter += 1

if counter == 0 :
    print(qq)
else :
    print(1)
    
print(D)
print(counter)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def gcd(target):
    before = target[0]
    result = before
    for count in range(1,len(target)-1):
        while before:
            result,before = before,target[count] % before
    
    return result    
N,X = map(int,input().split())

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] -X)

ans = gcd(absList)

    
print(ans)

Submission status: Wrong Answer

Solution code:
import functools
import fractions

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

if N == 1:
    print(abs(x[0] - X))
    exit()

x.append(X)
x.sort()
#print(x)

dist = []
for i in range(N-1):
    dist.append(abs(x[i] - x[i+1]))

gcd = functools.reduce(fractions.gcd, dist)
print(gcd)