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:
from fractions import gcd
from functools import reduce
n,x = map(int,input().split())

l=list(map(int,input().split()))
if n==1:
    print(abs(n-l[0]))
    exit(0)

l=list(map(lambda i: abs(i-x),l))

x = reduce(gcd,l)
print(x)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
n,x = map(int,input().split())
if n==1:
    print(abs(n-x))

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

print(n,x)
print(l)

l=list(map(lambda i: abs(i-x),l))
print(l)

x = reduce(gcd,l)
print(x)

Submission status: Wrong Answer

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

for i in range(n):
  l[i]=abs(l[i]-x)
print(l)

def gcd(x,y):
    if y==0:
      return x
    else:
      return gcd(y,x%y) 
    
if n==1:
  x=l[0]
else:
  x=gcd(l[0],l[1])
  if n>2:
    for i in range(2,n):
      x=gcd(x,l[i])
print(x)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=map(int, input().split())
x = list(map(int, input().split())) + [x]
x.sort()
print(x)
ret = x[1] - x[0]

for i in range(1, n):
    ret = gcd(ret, x[i+1] - x[i])

print(ret)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,x=map(int, input().split())
x = list(map(int, input().split())) + [x]
x.sort()

ret = x[1] - x[0]

for i in range(1, n-1):
    ret = gcd(ret, x[i+1] - x[i])

print(ret)

Submission status: Wrong Answer

Solution code:
def gcm(a,b):
    g = max(a,b)
    s = min(a,b)
    while g % s != 0:
        g = max(g,s)
        s = min(g,s)
        g = g % s
    return s

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

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcm(c,m)

    print(m)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def gcm(a,b):
    g = max(a,b)
    s = min(a,b)
    while g % s != 0:
        g = g % s
    return s

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

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    X.sort()
    m = X[0]
    for c in X[1:]:
        if c % m == 0:
            m = gcm(c,m)

    print(m)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, X = list(map(int, input().split()))
xlist = sorted(list(map(int, input().split())))
m = 1e11
for i in range(1, len(xlist)):
    m = min(m, xlist[i] - xlist[i - 1])

for x in [x for x in xlist if x != X]:
    m = min(abs(x - X), m)
print(m)

Submission status: Wrong Answer

Solution code:
N, X = list(map(int, input().split()))
xlist = sorted(list(map(int, input().split())))
m = 1e10
for i in range(1, len(xlist)):
    m = min(m, xlist[i] - xlist[i - 1])

for x in xlist:
    m = min(m,abs(X-x))

print(m)

Submission status: Wrong Answer

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist_2 = list(map(lambda x:abs(X - x), xlist))
flg = 0

sum = sum(xlist_2)
min = min(xlist_2)

for i in range(min):
    if sum % (min - i) == 0:
        print(min - i)
        flg = 1
        break
    print(flg)

Submission status: Wrong Answer

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist_2 = list(map(lambda x:abs(X - x), xlist))
flg = 0

sum = sum(xlist_2)
min = min(xlist_2)

#math.ceil(sum/2) int(sum/2)
#print(N)

for i in range(min):
    if sum % (min - i) == 0:
        print(min - i)
        flg = 1
        break
if flg == 0:
    print(1)

Submission status: Wrong Answer

Solution code:
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist_2 = list(map(lambda x:abs(X - x), xlist))
flg = 0

sum = sum(xlist_2)
min = min(xlist_2)

#math.ceil(sum/2) int(sum/2)
#print(N)

for i in range(N):
    if sum % (min - i) == 0:
        print(min - i)
        flg = 1
        break
if flg == 0:
    print(1)

Submission status: Wrong Answer

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

diffs = list(set([abs(x - X) for x in x_list]))

print(min(diffs))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
n,X = map(int,input().split())
a = sorted(list(map(int,input().split())))
ind = bisect_right(a,X)
if ind == 0:
    print(a[0]-X)
elif ind == n:
    print(X-a[ind-1])
else:
    print(min(a[ind]-X,X-a[ind-1]))

Submission status: Wrong Answer

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


print(abc109_c())

Submission status: Wrong Answer

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.diff(xn)
print(reduce(fractions.gcd, xn))

Submission status: Wrong Answer

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))
x.sort()
print(gcd(x[0],x[1]))

Submission status: Wrong Answer

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[0] - X))
print(mod)

Submission status: Wrong Answer

Solution code:
def factor(num):
  tmp = num
  a = 2
  res = {}
  while a * a < num:
    while tmp % a == 0:
      if a in res:
        res[a] += 1
      else:
        res[a] = 1
      tmp /= a
    a+=1
  if tmp > 1:
    res[int(tmp)]=1
  return res

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
cities.append(X)
cities.sort()
ans_dict = factor(cities[1] - cities[0])
for i in range(1, N):
  res = factor(cities[i+1] - cities[i])
  set_keys = set(res) & set(ans_dict)
  ans_dict = {key: min(res[key], ans_dict[key]) for key in set_keys}

ans = 1
for i, j in ans_dict.items():
  ans *= i**j
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
i = bisect.bisect_left(x, X)
if N == 1:
    i = 0
elif i >= 1:
    i = i - 1
elif i == 0:
    i = i + 1
ab = abs(x[i] - X)
for j in range(N - 1):
    if not(x[j + 1] % ab):
       print(bcd(x[j + 1], x[j]))
       sys.exit()
print(ab)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
i = bisect.bisect_left(x, X)
if N == 1:
    i = 0
elif i >= 1:
    i = i - 1
elif i == 0:
    i = i + 1
print(abs(x[i] - X))

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
i = bisect.bisect_left(x, X) - 1
if N == 1:
    i = 0
elif i < 0:
    i = 1
elif i >= N:
    i = i - 1
print(abs(x[i] - X))

Submission status: Wrong Answer

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

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

min_n = 10**9
i = 0
while i + 1 < len(nums):
  if min_n > nums[i+1]-nums[i]:
    min_n = nums[i+1]-nums[i]
  i+=1

print(min_n)

Submission status: Wrong Answer

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

print(nums[1]-nums[0])

Submission status: Wrong Answer

Solution code:
import collections

inputs=[]
N,X=map(int,input().split())
inputs =list(map(int, input().split()))
D=[]
for i in range(len(inputs)):
    D.append(abs(X-inputs[i]))
uniqueD=list(set(D))
uniqueD.sort(reverse=True)
inputs.append(X)
inputs.sort()
first=inputs[0]
last=inputs[len(inputs)-1]
for item in uniqueD:
    count=0
    for i in range(first,last+1,item):            
        for j in range(len(inputs)):
            if(inputs[j]==i):
                count+=1
                break   
    if(N==count-1):
        print(item)
        break

Submission status: Wrong Answer

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

uniqueD=list(set(D))
uniqueD.sort(reverse=True)
first=inputs[0]
last=inputs[len(inputs)-1]
for item in uniqueD:
    count=0
    for i in range(first,last+1,item):            
        for j in range(len(inputs)):
            if(inputs[j]==i):
                count+=1
                break   
    if(N==count-1):
        print(item)
        break

Submission status: Wrong Answer

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

uniqueD=list(set(D))
uniqueD.sort(reverse=True)
first=inputs[0]
last=inputs[len(inputs)-1]
newArr=[]
for item in uniqueD:
    count=0
    for i in range(first,last+1,item):
        newArr.append(i)        
        for j in range(len(inputs)):
            if(inputs[j]==i):
                count+=1
                break   
    if(N==count-1):
        print(item)
        break

Submission status: Wrong Answer

Solution code:
import collections
inputs=[]
N,X=map(int,input().split())
inputs =list(map(int, input().split()))
inputs.append(X)
inputs.sort()
var=[]
for i in range(1,len(inputs)):
    var.append(inputs[i]-inputs[i-1])

unique=list(set(var))
unique.sort(reverse=True)

minI=min(inputs)
maxI=max(inputs)
newArr=[]


for item in unique:
    i = minI
    newArr.append(i)
    while i < maxI:
        sumI=i+item
        newArr.append(sumI)  
        i = sumI
    count=0
    for j in range(len(inputs)):
        flag=False
        for k in range(len(newArr)):
            if(inputs[j]==newArr[k]):
                flag=True
                count+=1
                break
    #print(newArr)
    #print(count)
    if(N==count-1):
        print(item)
        break

Submission status: Wrong Answer

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]

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

    return max(sol)


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

Solution code:
inputs=[]
N,X=map(int,input().split())
inputs =list(map(int, input().split()))
inputs.append(X)
inputs.sort()
print(inputs[1]-inputs[0])

Submission status: Wrong Answer

Solution code:
n, X = map(int, input().split())
x = list(map(int, input().split()))
sa = 1e9
for i in range(n):
    if abs(x[i] - X) < sa:
        sa = abs(x[i] - X)
print(sa)

Submission status: Wrong Answer

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(abs(X-a[0]))
else:
    ans = gcd(a[0], a[1])
    for i in range(N):
        ans = gcd(ans, a[i])
    print(ans)

Submission status: Wrong Answer

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=abs(y-z)
t=[]
for i in range(1,n):
    t.append(y[i]-y[i-1])

print(gcd_list(t))

Submission status: Wrong Answer

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
t=[]
for i in range(1,n):
    t.append(abs(y[i]-y[i-1]))

print(gcd_list(t))

Submission status: Wrong Answer

Solution code:
import fractions

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

li.append(x)

a = list(map(int, input().split()))
l = li + a

l.sort()
print(l)
ans = []
for i in range(1, len(l)):
    ans.append(l[i] - l[i-1])
    
d = ans[0]
for i in range(len(ans)):
    d = fractions.gcd(d, ans[i])
    
print(d)

Submission status: Wrong Answer

Solution code:
import fractions

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

li.append(x)

a = list(map(int, input().split()))
l = li + a

l.sort()
print(l)
ans = []
for i in range(1, n+1):
    ans.append(l[i] - l[i-1])
    
d = ans[0]
for i in range(n):
    d = fractions.gcd(d, ans[i])
    
print(d)

Submission status: Wrong Answer

Solution code:
import fractions

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

li.append(x)

a = list(map(int, input().split()))
l = li + a

l.sort()
print(l)
ans = []
for i in range(1, n+1):
    ans.append(l[i] - l[i-1])
    
d = ans[0]
for i in range(n-1):
    d = fractions.gcd(d, ans[i])
    
print(d)

Submission status: Wrong Answer

Solution code:
import fractions

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

li.append(x)

a = list(map(int, input().split()))
l = li + a

if n == 1:
    print(abs(l[0] - l[1]))

else:
    l.sort()
    ans = []
    for i in range(1, n):
        ans.append(l[i] - l[i-1])
    
    d = ans[0]
    for i in range(n-1):
        d = fractions.gcd(d, ans[i])
    
    print(d)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

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

li.append(x)

a = list(map(int, input().split()))
l = li + a

if n == 1:
    print(abs(l[0] - l[1]))

else:
    l.sort()
    ans = []
    for i in range(1, n):
        ans.append(l[i] - l[i-1])
    
    d = ans[0]
    for i in range(n-1):
        d = fractions.gcd(d, ans[i])
    
    print(d)

Submission status: Wrong Answer

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


n, large_x = map(int, input().split())
x = (list(map(int, input().split())))
d = -1
if n == 1:
    print(abs(x[0] - large_x))
    exit()
for i in range(n):
    x[i] = x[i] - large_x
for i in range(n):
    if d == -1:
        d = gcd(x[0], x[1])
    d = gcd(d, x[i])
print(d)

Submission status: Wrong Answer

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

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

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

print(l[0])

Submission status: Wrong Answer

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

p.append(x)
p = sorted(p)

a = float('inf')
b = float('inf')
index = p.index(x)

if index - 1 >= 0:
  a = x - p[index-1]

if index + 1 < len(p):
  b = p[index+1] - x

left = p[:index]
right = p[index+1:]

def f():

  for i in left:
    if not (x-i) % a == 0:
      return b
  
  for i in right:
    if not (i-x) % a == 0:
      return b
  return a

print(f())

Submission status: Wrong Answer

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

p.append(x)
p = sorted(p)

left = float('inf')
right = float('inf')
index = p.index(x)

if index - 1 >= 0:
  left = p[index-1]

if index + 1 < len(p):
  right = p[index+1]

greater = max(abs(x-left), abs(x-right))
for i in range(len(p)):
  p[i] -= greater

def f():
  
  for i in p:
    if not i % greater == 0:
      return min(abs(x-left), abs(x-right))
  
  return greater

print(f())

Submission status: Wrong Answer

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

N, X = map(int,input().split())
I = list(map(int,input().split()))
I.append(X)
sI = sorted(I)
L = []
for i in range(len(sI)-1):
    L_i = sI[i+1] - sI[i]
    L.append(L_i)
sL = sorted(L)
if len(sL) == 1:
    print(sL[0])
else:
    while True:
        X = gcd(sL[0],sL[1])
        if len(sL) > 2:
            del sL[0],sL[1]
            sL.insert(0, X)
        else:
            print(X)
            break

Submission status: Wrong Answer

Solution code:
nx = []
x = []
sus = []
nx = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(nx[1])
sorted(x)

for i in range(nx[0]):
    sus.append(x[i + 1] - x[i])
else:
    sorted(sus)


for i in range(len(sus) - 1):
    a = sus[i]
    b = sus[i + 1]
    r = a % b
    x = a * b
    while r != 0:
        a = b
        b = r
        r = a % b
    else:
        sus[i + 1] = b
else:
    if sus[len(sus) - 1] % 2 != 0 or sus[len(sus) - 1] == -2:
        sus[len(sus) - 1] *= -1
    print(sus[len(sus) - 1])

Submission status: Wrong Answer

Solution code:
nx = []
x = []
sus = []
nx = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(nx[1])
sorted(x)

for i in range(nx[0]):
    sus.append(x[i + 1] - x[i])
else:
    sorted(sus)


for i in range(len(sus) - 1):
    a = sus[i]
    b = sus[i + 1]
    r = a % b
    x = a * b
    while r != 0:
        a = b
        b = r
        r = a % b
    else:
        sus[i + 1] = b
else:
    if sus[len(sus) - 1] % 2 != 0:
        sus[len(sus) - 1] *= -1
    print(sus[len(sus) - 1])

Submission status: Wrong Answer

Solution code:
nx = []
x = []
sus = []
nx = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(nx[1])
sorted(x)

for i in range(nx[0]):
    sus.append(x[i + 1] - x[i])
else:
    sorted(sus)


for i in range(len(sus) - 1):
    a = sus[i]
    b = sus[i + 1]
    r = a% b
    x = a * b
    while r != 0:
        a = b
        b = r
        r = a % b
    else:
        sus[i + 1] = b
else:
    print(int(sus[len(sus) - 1]))

Submission status: Wrong Answer

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

min_distance = 10 ** 9
for i in x: min_distance = min(abs(i - X), min_distance)

print(min_distance)

Submission status: Wrong Answer

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)]
print(difference)
print(gcd([2, 4, 6, 8]))

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

Solution code:
import math
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
print(difference)
"""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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import io
import sys
import math
from functools import reduce

def gcd_list(numbers):#最大公約数を求める
    return reduce(math.gcd, numbers)

Submission status: Wrong Answer

Solution code:
n,d=list(map(int,input().split()))
lis=list(map(int,input().split()))
lis+=[d]
lis.sort()
ans=float("inf")
for i in range(len(lis)-1):
  ans=min(lis[i+1]-lis[i],ans)
print(ans)

Submission status: Wrong Answer

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 = [x[i+1]-x[i] for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

Submission status: Wrong Answer

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

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

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

min = 10000000000
answer = 1
y = list(range(N))

for i in range(N):
	y[i] = abs(x[i]-X)
	if min > y[i]:
		min = y[i]

for i in range(1, min+1):
	if min%i == 0:
		if sum(y)%i == 0:
			answer = i

print(answer)

Submission status: Wrong Answer

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

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

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

min = 10000000000
answer = 1
y = list(range(N))

for i in range(N):
	y[i] = abs(x[i]-X)
	if min > y[i]:
		min = y[i]

for i in range(1, min+1):
	if min%i == 0:
		if sum(y)%i == 0:
			answer = i

print(min,answer)

Submission status: Wrong Answer

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

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

Submission status: Wrong Answer

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

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    ans = 0
    gcd_l = []
    gcd_l.append(abs(X-x[0]))

    for i in range(1,N):
        gcd_l.append(abs(x[i-1]-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        for n in range(1,len(gcd_l)):
            a = [gcd_l[n-1],gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

Submission status: Wrong Answer

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

ux=x+[X]
count = 0
ans = 0
for n in range(1,max(x)+1):
    j = [i for i in range(min(ux),max(ux)+1,n)]
    if len(j)>=N:
        for xx in x:
            if xx in j:
                count += 1
            if count == N:
                ans = n
    count = 0
print(ans)

Submission status: Wrong Answer

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

ux=x+[X]
count = 0
ans = 0
for n in range(1,max(x)+1):
    j = [i for i in range(min(ux),max(ux)+1,n)]
    for xx in x:
        if xx in j:
            count += 1
    if count == N:
        ans = n
    count = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import io
import sys

def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)

    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    listb = []
    
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    listd += listb
    return min(listd)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import io
import sys


def solve(lista,x):
    listd = []
    listc1 = []
    listc1 += lista
    listc1.append(x)
    listc = sorted(listc1)

    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    listb = []
    
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    listd += listb
    return min(listd),listd

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import io
import sys

def solve(lista,x):
    listb = []
    listd = []
    listc1 = lista
    listc1.append(x)
    listc = sorted(listc1)
    
    for i in range(len(listc)-1):
        ans = listc[i+1] - listc[i]
        listd.append(ans)
        
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    return min(listd)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import io
import sys



def solve(lista,x):
    listb = []
    for i in lista:
        if i > x:
            ans = i-x
            listb.append(ans)
        else:
            ans = x-i
            listb.append(ans)
    return min(listb)

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():

    line1 = sys.stdin.readline().rstrip()
    list1 = line1.split(" ")
    line2 = sys.stdin.readline().rstrip()
    list2 = line2.split(" ")
    list3 = [int(a) for a in list2]
    return [list3,int(list1[1])]

def main():
    n,x = readQuestion()
    answer = solve(n,x)
    print(answer)
    
if __name__ == '__main__':
    main()

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 = []
X_S = abs(npX - S)

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


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

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

for div in divs[::-1]:
    tmp = X_S % div
    if max(tmp) == 0:
        print(div)
        exit()


# 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 = sorted(X)
npX = np.array(X)

X_del = []
X_S = npX - S

for i in range(N-1):
    X_del.append(npX[i+1] - npX[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]:
    tmp = X_S % div
    if max(tmp) == 0:
        print(div)
        exit()


# 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()