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 sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


def main():
    N, X = MAP()
    x = LIST()

    if N == 1:
        print(max(1000000000 - X, X - 1))
        sys.exit()

    print(make_divisors(72))

    for d in make_divisors(max(x)-min(x)):
        for i in range(N):
            if abs(X - x[i]) % d != 0: break
        else:
            print(d)
            sys.exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


def main():
    N, X = MAP()
    x = LIST()

    if N == 1: print(max(1000000000 - X, X - 1))

    for d in make_divisors(max(x)-min(x)):
        for i in range(N):
            if (X - x[i]) % d != 0: break
        else:
            print(d)
            sys.exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import functools

N, X = map(int, input().split())
cities = []
for city in list(map(int, input().split())):
    cities.append(city - X)
print(functools.reduce(fractions.gcd, cities))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,X=map(int, input().split())
x=list(map(int,input().split()))
D=1
for i in range(min(abs(np.array(X)-x)),max(abs(np.array(X)-x))+1):
  if all([abs(j-X)%i==0 for j in x]):
    D=i
print(D)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x = map(int,input().split())
a = list(map(int, input().split()))
b = [0]*(n-1)
for i in range(n-1):
    b[i]= a[i+1]-a[i]
c = 0
for j in b:
    c = gcd(c, j)
print(c)

Submission status: Wrong Answer

Solution code:
import fractions

n, s = map(int, input().split())
x = list(map(int, input().split()))
x.append(s)
m = min(x)
xr = [e - m for e in x]
ans = xr[0]
for i in range(1, n-1):
    ans = fractions.gcd(ans, i)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

n, s = map(int, input().split())
x = list(map(int, input().split()))
x.append(s)
m = min(x)
xr = [e - m for e in x]
if n <= 2:
    gcd = fractions.gcd(xr[0], xr[1])
    print(gcd)
    exit()
gcd = fractions.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = fractions.gcd(gcd, i)
print(gcd)

Submission status: Wrong Answer

Solution code:
import fractions

n, s = map(int, input().split())
x = list(map(int, input().split()))
x.append(s)
m = min(x)
xr = [e - m for e in x]
if n == 2:
    gcd = fractions.gcd(xr[0], xr[1])
    print(gcd)
    exit()
gcd = fractions.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = fractions.gcd(gcd, i)
print(gcd)

Submission status: Wrong Answer

Solution code:
import fractions

n, x = map(int, input().split())
x = list(map(int, input().split()))
m = min(x)
xr = [e - m for e in x]
if n == 1:
    gcd = xr[0]
    print(gcd)
    exit()
elif n == 2:
    gcd = fractions.gcd(xr[0], xr[1])
    print(gcd)
    exit()
gcd = fractions.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = fractions.gcd(gcd, i)
print(gcd)

Submission status: Wrong Answer

Solution code:
import fractions

n, x = map(int, input().split())
x = list(map(int, input().split()))
m = min(x)
xr = [e - m for e in x]
if n == 1:
    gcd = xr[0]
    print(gcd)
    exit()
gcd = fractions.gcd(xr[0], xr[1])
for i in xr[2:]:
    gcd = fractions.gcd(gcd, i)
print(gcd)

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int, input().split())
*l,=map(int, input().split())
l.append(x)
l.sort(reverse=True)
ans=0
sa1=0
sa2=0
if n==1:
    print(abs(x-l[0]))
else:
    for i in range(n-1):
        sa1=l[i]-l[i+1]
        sa2=l[i+1]-l[i+2]
        ans=fractions.gcd(fractions.gcd(sa1,sa2),ans)
    print(ans)

Submission status: Wrong Answer

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

D = float("inf")
for i in range(N):
    D = min(D, abs(X - x[i]))
print(D)

Submission status: Wrong Answer

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

D = float("inf")
for i in range(N):
    D = min(D, x[i] - x[i + 1])
print(D)

Submission status: Wrong Answer

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

D = 10**9
for i in range(N):
    D = min(D, x[i] - x[i + 1])
print(D)

Submission status: Wrong Answer

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

n,x = map(int,input().split())
lstx = [int(i) for i in input().split()]
lstx.append(x)
dx = [abs(lstx[i]-lstx[i-1]) for i in range(1,n+1)]

g = dx[0]
for i in range(1,n-1): 
    g = gcd(g,dx[i])

print(g)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

n,s=map(int,input().split())
x=list(map(int,input().split()))
x2=[]
for i in x:
    x2.append(abs(i-s))

gcd_list(x2)

Submission status: Wrong Answer

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

ans = float("inf")
for i in range(N):
    ans = min(ans, abs(x[i] - X))

print(ans)

Submission status: Wrong Answer

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

x.append(X)
x.sort()
ans = float("inf")

for i in range(N):
    ans = min(ans, abs(x[i]-x[i+1]))

print(ans)

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if abs(x[i]-X)==0:
        continue
    x[i]=abs(x[i]-X)
print(min(x))

Submission status: Wrong Answer

Solution code:
import fractions

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

g = abs(x[0] - X)
m = abs(x[0] - X)
for i in range(len(x)-1):
    g = fractions.gcd(g, x[i+1] - x[i])
    m = min(m, x[i+1] - x[i])

print(max(g, m))

Submission status: Wrong Answer

Solution code:
import fractions

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
n, X = map(int, input().split())
*x, = sorted(map(int, input().split()))

bisect.insort_left(x, X)
ans = float("inf")
for i in range(len(x)-1):
    ans = min(ans, x[i+1] - x[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if len(x) == 1:
    print(abs(X-x[0]))
    sys.exit()
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(D)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(D)

Submission status: Wrong Answer

Solution code:
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x = y
        y = x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
Y.sort()
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x = y
        y = x%y
    return x

N,X = map(int,input().split())
Y = [abs(X-int(i)) for i in input().split()]
ans = Y[0]
for i in range(N-1):
    ans = p(ans,Y[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x = y
        y = x%y
    return x

N,X = map(int,input().split())
Y = list(map(int,input().split()))
Y.append(X)
Y.sort()
l = [0]*N
for i in range(N):
    l[i]=abs(Y[i+1]-Y[i])
ans = l[0]
for i in range(N-1):
    ans = p(ans,l[i+1])
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
n,x = list(map(int,input().split()))
x_list = list(map(int,input().split()))
#xとx_listをまとめて考える。
x_list += [x]
x_list.sort()
x_dif_list = [i-j for i,j in zip(x_list[1::],x_list)]

#最大公約数
import fractions

ret = x_dif_list[0]
#最大公約数を取る
for i in x_dif_list:
    i = fractions.gcd(ret, i)
    if i==1:
        break
print(ret)

Submission status: Wrong Answer

Solution code:
from statistics import median
from fractions import gcd

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

ans = abs(median(x) - X)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from statistics import median
from fractions import gcd

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

a = max(x) - median(x)
b = median(x) - min(x)
c = abs(median(x) - X)

temp = gcd(a, b)
ans = gcd(temp, c)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions

def lcm(a,b):
    return fractions.gcd(a,b)

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

map_len = []
for i in range(N):
    map_len.append(abs(X - map_list[i]))

gcm = 0
for i in range(len(map_len) - 1):
    gcm = fractions.gcd(map_len[i], map_len[i + 1])
    i += 1

print(gcm)

Submission status: Wrong Answer

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

map_len = []
for i in range(N):
    map_len.append(abs(X - map_list[i]))

print(min(map_len))

Submission status: Wrong Answer

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

res_abs = []
res = []

s = 10**10

for i in range(n):
    s = abs(li[i] - x)
    res_abs.append(s)
    
    s = li[i] - x
    res.append(s)
    
res.sort()

temp = 10**10

for i in range(n-1):
    temp = min(temp, res[i+1] - res[i])
    
    
s = min(min(res), temp)
    
while True:
    for i in range(n):
        if res_abs[i]%s != 0:
            break
    else:
        print(s)
        exit()
        
    s -= 1

Submission status: Wrong Answer

Solution code:
# coding: utf-8
try:
    from math import gcd
except:
    from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(x[0] - X))
    exit()
x.sort()
l = []
ans = 10**10
for i in range(len(x)-1):
    if x[i] < X < x[i+1]:
        tmp = abs(X - x[i])
    else:
        tmp = abs(x[i] - x[i+1])
    if tmp != 0:
        ans = min(ans, tmp)
    l.append(tmp)
l.sort()
for i in range(len(l)-1):
    ans = gcd(l[i], l[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, X = map(int, input().split())
x = list(map(int, input().split()))
#x.sort()
l = []
for i in range(len(x)):
    l.append(abs(X - x[i]))
print(min(l))

Submission status: Wrong Answer

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

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

for xx in x:
    ans = gcd(x[0],xx)
print(ans)

Submission status: Wrong Answer

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

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

for xx in x:
    ans = lcm(x[0],xx)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=list(map(int, input().split()))
a=list(map(int, input().split()))
ans=a[0]-x
for i in a:
    ans=gcd(ans,i-x)
print(ans)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
e=[]
for i in range(n):
  d.append(r[i+1]-r[i])
d=list(set(d))
#print(d)
while len(d)>1:
  for i in range(len(d)-1):
    if d[i+1]!=d[i]:
      e.append(d[i+1]-d[i])
  d=e[:]
  d=list(set(d))
  d.sort()
print(*d)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
dif = [abs(x[i+1]-x[i]) for i in range(N-1)]
ans = x[0]-X
for i in range(N-1):
    ans = gcd(ans,dif[i])
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
dif = [x[0]-X]+[x[i+1]-x[i] for i in range(N-1)]
ans = dif[0]
for i in range(1,N):
    ans = gcd(ans,dif[i])
print(ans)

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=map(int, input().split())
Towns=list(map(int, input().split()))
dist=[]
for i in Towns:
    dist.append(abs(i-X))

GCD = gcd(*dist)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
d = []
min=abs(x[0]-X)
for i in range(N):
    d.append(abs(x[i] - X))
    if d[i] < min:
        min = d[i]
if  sum(list(map(lambda x: x % min, d)))== 0:
    print(min)
elif sum(list(map(lambda x: x % 2, d)))==0:
    print(2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
d = []
min=abs(x[0]-X)
for i in range(N):
    d.append(abs(x[i] - X))
    if d[i] < min:
        min = d[i]
ans=sum(list(map(lambda x: x % min, d)))
if  ans== 0:
    print(min)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import fractions

n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x2=sorted(x)
ans=x2[1]-x2[0]
for i in range(1,n-1):
    b=x2[i+1]-x2[i]
    ans=fractions.gcd(ans,b)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np

def diff_list(ls):
    ls_a = ls.copy()
    ls_a.append(ls[-1])
    return np.array(ls_a[1:]) - np.array(ls)
 
def solve(N: int, X: int, x: "List[int]"):
    ans = abs(X-x[0])
    xa = x.copy()
    xa.append(X)
    xs = sorted(xa)
    if len(x) > 1:
        xs_diff = diff_list(xs)
        ans = min(xs_diff[:-1])
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np

def diff_list(ls):
    ls_a = ls.copy()
    ls_a.append(ls[-1])
    return np.array(ls_a[1:]) - np.array(ls)
 
def solve(N: int, X: int, x: "List[int]"):
    ans = abs(X-x[0])
    x.append(X)
    xs = sorted(x)
    if len(xs) > 1:
        xs_diff = diff_list(xs)
        ans = min(xs_diff[:-1])
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
a.sort()
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=min(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=min(abs(x-a[i]),ans)
    print(fractions.gcd(ans,cnt))

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
a.sort()
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=min(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=min(abs(x-a[i]),ans)
    print(min(ans,cnt))

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=abs(x-a[0])
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=min(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=min(abs(x-a[i]),ans)
    print(fractions.gcd(ans,cnt))

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=min(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=min(abs(x-a[i]),ans)
    print(fractions.gcd(ans,cnt))

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=min(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=min(abs(x-a[i]),ans)
    print(min(ans,cnt))

Submission status: Wrong Answer

Solution code:
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
for i in range(n):
    ans=min(abs(x-a[i]),ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = [int(x) for x in input().split()]
xn = sorted(list(set([abs(int(x) - X) for x in input().split()])))
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)

if N == 1:
  print(xn[0])
else:
  n = (gcd(xn[0], xn[1]))
  for x in xn:
    if x % n != 0:
      print(1)
      exit()
  else:
    print(n)

Submission status: Wrong Answer

Solution code:
N, X = [int(x) for x in input().split()]
xn = sorted(list(set([abs(int(x) - X) for x in input().split()])))
def gcd(a, b):
  if b % a == 0:
    return a
  return gcd(b % a, a)

if N == 1:
  print(xn[0])
else:
  n = (gcd(xn[0], xn[1]))
  for x in xn:
    if x % n != 0:
      print(1)
      exit()
  else:
    print(n)

Submission status: Wrong Answer

Solution code:
N, X = [int(x) for x in input().split()]
xn = sorted(list(set([abs(int(x) - X) for x in input().split()])))
def gcd(a, b):
  if b % a == 0:
    return a
  return gcd(b % a, a)

if N == 1:
  print(xn[0])
else:
  print(gcd(xn[0], xn[1]))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = city[i] - X
    
def gcd(numbers):
    return reduce(fractions.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

Submission status: Wrong Answer

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

d = [l[i+1] - l[i] for i in range(n)]

d.sort()
mi = d[0]

for i in d:
    if i % mi != 0:
        print(1)
        exit()

print(mi)

Submission status: Wrong Answer

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

d = [l[i+1] - l[i] for i in range(n)]
print(min(d))

Submission status: Wrong Answer

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

diff = []

for i in range(N):
  diff.append(abs(D- X[i]))
  
first = min(diff)

con = 0

for i in range(N):
  if diff[i] % first == 0:
    con += 1
if con == N:
  print(first)
else:print(1)

Submission status: Wrong Answer

Solution code:
import fractions

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

for n in range(N):
    x[n] = abs(x[n]-X)
ans = 10000000000
for n in range(N):
    if x[n] != 0:
        ans = fractions.gcd(ans,x[n])
print(ans)

Submission status: Wrong Answer

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

x.append(X)
x.sort()
res = 10**12

for i in range(N):
    res = min(x[i+1]-x[i], res)

print(res)

Submission status: Wrong Answer

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

x.append(X)
x.sort()
res = 10**12

for i in range(N-1):
    res = min(x[i+1]-x[i], res)

print(res)

Submission status: Wrong Answer

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

M = [abs(i - X) for i in L]

D = []


for m in range(0,len(M)):
  for i in range(0,len(M)):
    if M[m] % M[i] == 0:
      D.append(M[m])
      
print(max(D))

Submission status: Wrong Answer

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

M = [abs(i - X) for i in L]

m = min(M)

for i in range(0,len(M)):
  if M[i] % m > 0:
    print(1)
    break
else:print(m)

Submission status: Wrong Answer

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

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

M = sorted([abs(i - X) for i in L])

m = min(M)

if m == 0:
  print(m)
else:
  for i in range(0,len(M)):
    if M[i] % m > 0:
      print(1)
      break
  else:print(m)

Submission status: Wrong Answer

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

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

M = sorted([abs(i - X) for i in L])

m = min(M)

print(M)

if m == 0:
  print(m)
else:
  for i in range(0,len(M)):
    if M[i] % m > 0:
      print(1)
      break
  else:print(m)

Submission status: Wrong Answer

Solution code:
import fractions

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

L = list(map(int,input().split()))
y = []
for i in range(n):
  y.append(abs(L[i]-x))
tmp = y[0]

for i in range(n-1):
  tmp = fractions.gcd(tmp,L[i+1])
print(tmp)

Submission status: Wrong Answer

Solution code:
import fractions

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

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


if n == 1:
  print(abs(L[0]-x))
  exit()
else:
  L.append(x)
  L = sorted(L)
  a = L[1]-L[0]
  for i in range(n-1):
    b = L[i+1]-L[i]
    a = fractions.gcd(a,b)
print(a)

Submission status: Wrong Answer

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

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

M = sorted([abs(i - X) for i in L])

m = min(M)

diff_min = max(L)
min_id = 0

for i in range(N):
  diff = abs(L[i] - X)
  if diff_min > diff:
    diff_min = diff
    min_id = L[i]
    
for i in range(N):
  diff = L[i] - min_id
  if diff % diff_min > 0:
    print(1)
    break
else:print(diff_min)

Submission status: Wrong Answer

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

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

M = sorted([abs(i - X) for i in L])

m = min(M)

for i in range(0,len(M)):
  if M[i] % m != 0:
    print(1)
    break
else:print(m)

Submission status: Wrong Answer

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

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

M = min([abs(i - X) for i in L])

print(M)

Submission status: Wrong Answer

Solution code:
n,s=map(int,input().split())
l=[abs(int(i)-s) for i in input().split()]
ans=l[0]
for i in l:
  a=ans
  b=0
  while a and i:
    a//=i
    b=a
    a=i
    i=b
  ans=max(a,i)
print(ans)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
for i in range(n):
  d.append(r[i+1]-r[i])
#d=list(set(d))
#d.sort()
#print(d)
print(min(d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [i - X for i in ary]
ans = arr[0]
for i in range(1,N):
    ans = fractions.gcd(ans, arr[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
ary = list(map(int, input().split()))
arr = [i - X for i in ary]
ans = arr[0]
for i in range(1,N-1):
    ans = fractions.gcd(ans, arr[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
P=sorted(list(map(int,input().split())))
P=[i-X for i in P]
D=[P[i+1]-P[i] for i in range(N-1)]

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

if len(P)==1:
    print(abs(P[0]))
else:
    print(gcd_list(D))

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
P=sorted(list(map(int,input().split())))
P=[i-X for i in P]
D=[P[i+1]-P[i] for i in range(N-1)]

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

if len(P)==1:
    print(P[0])
else:
    print(gcd_list(D))

Submission status: Wrong Answer

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

import sys
if len(x) == 1:
  print(abs(X-x[0]))
  sys.exit()
  
x.sort()
x = [xx+X for xx in x]
between = [x[i+1]-x[i] for i in range(n-1)]

import fractions
from functools import reduce

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

Submission status: Wrong Answer

Solution code:
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
min_x = 10**9+1
for i in range(N):
    y = math.fabs(X-x[i])
    y = int(y)
    if y == 0:
        continue
    if y < min_x:
        min_x = y
print(int(min_x))

Submission status: Wrong Answer

Solution code:
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
min_x = 10**9+1
for i in range(N):
    y = math.fabs(X-x[i])
    y = int(y)
    if y < min_x:
        min_x = y
print(int(min_x))

Submission status: Wrong Answer

Solution code:
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
min_x = 10**9+1
for i in range(N):
    y = math.fabs(X-x[i])
    if y < min_x:
        min_x = y
print(int(min_x))

Submission status: Wrong Answer

Solution code:
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
min_x = 10**9+1
for i in range(N):
    y = math.fabs(X-x[i])
    if y < min_x:
        min_x = y
print(min_x)

Submission status: Wrong Answer

Solution code:
N, X = map(int,input().split())
x = list(map(int,input().split()))
min_x = 10**9+1
for i in range(N-1):
    y = x[i+1] - x[i]
    if y < min_x:
        min_x = y
print(min_x)

Submission status: Wrong Answer

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

x.append(X)
x = sorted(x)
diff_x = []
for i in range(len(x)-1):
    diff_x.append(x[i+ 1] - x[i])

min = min(diff_x)
diff = 0
for i in range(len(diff_x)):
    diff = diff_x[i]
    while(i < len(diff_x)):
        if diff == min:
            break
        elif diff_x[i] % min != 0: # 最小ステップで割り切れない場合
            print("1")
            exit()
        else: # 最小ステップで割り切れる場合
            diff = diff / min
print(min)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*n
for i in range(n):
  a[i]=l[i]-x
a.sort()
from fractions import gcd
from functools import reduce
def gcdl(list):
  return reduce(gcd,list)
if len(a)>1:
  print(gcdl(a))
else:
  print(a[0])

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*n
for i in range(n):
  a[i]=l[i]-x
a.sort()
from fractions import gcd
from functools import reduce
def gcdl(list):
  return reduce(gcd,list)
print(gcdl(a))

Submission status: Wrong Answer

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