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
n, x = map(int, input().split())
ans = 1
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()
    return divisors
def check(n, li):
    for i in li:
        if i != 0:
            if abs(i) % n != 0:
                return False
    return True
li = list(map(int, input().split()))
li.append(x)
li = list(set(li))
li.sort()
start_index = li.index(x)
li = np.array(li)
if start_index == len(li)-1:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div:
        if check(i, li-x) and i > ans:
            ans = i
            break
        
elif start_index == 0:
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div:
        if check(i, li-x) and i > ans:
            ans = i
            break
else:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div:
        if check(i, li-x) and i > ans:
            ans = i
            break
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div:
        if check(i, li-x) and i > ans:
            ans = i
            break
        if ans > i:
            break

print(ans)

Submission status: Wrong Answer

Solution code:
def g_c_m(x, y):
    if x == 0:
        return y
    elif y == 0:
        return x
    else:
        return g_c_m(y, x%y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = c[1]-c[0]
for i in range(1, a):
    d = g_c_m(d, c[i]-c[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.sort()

ans = X[1] - X[0]
for i in range(1, N):
    t = X[i+1] - X[i]
    if t < ans:
        ans = t
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 = X[1] - X[0]
for i in range(1, N-1):
    t = X[i+1] - X[i]
    if t < ans:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
# ABC 109, C - skip
import itertools

n, y = map(int, input().split(' '))
X = [int(el) for el in input().split(' ')]

max_d = y - min(X)

answer = 1
for i in range(1, max_d+1):
    d = max_d / i
    if d == int(d):
        for x in X:
            if (x - y) % int(d) != 0:
                break
        else:
            answer = d
            break
print(int(answer))

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())
A=list(map(int,input().split()))
B=[]

if N==1:
    print(abs(A[0]-X))
    exit(0)
for i in range(N):
    B.append(abs(X-A[i]))

a=gcd(B[0],B[1])
for i in range(2,N):
    a=gcd(a,B[2])
print(a)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

input = sys.stdin.readline

def main():
    N, X = map(int, input().split())
    x = [int(e) for e in input().split()]
    x.sort()

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

    m = []
    for i in range(N-1):
        m.append(x[i+1]-x[i])
    
    n = m[0]
    for i in m:
        n = gcd(n, i)
    print(n)

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

input = sys.stdin.readline

def main():
    N, X = map(int, input().split())
    x = [int(e) for e in input().split()]
    x.sort()

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

    m = []
    for i in range(N-1):
        m.append(x[i+1]-x[i])
    
    n = m[0]
    for i in m:
        n = gcd(n, i)
    print(n)

main()

Submission status: Wrong Answer

Solution code:
def c_gcd(x, y):
    if y == 0:
        return x
    else:
        return c_gcd(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if d == -1:
        d = c[i] - c[i-1]
    elif c[i] - c[i-1] < d:
        d = c_gcd(c[i] - c[i-1], d)
print(d)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if d == -1:
        d = c[i] - c[i-1]
    elif c[i] - c[i-1] < d:
        d = c[i] - c[i-1]
print(d)

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=list(map(int,input().split()))

ans = x[0] - X

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

print(abs(ans))

Submission status: Wrong Answer

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

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

print(gcd)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
lst = sorted([int(x) for x in input().split()] + [X])
n = lst[-1]
for idx in range(len(lst) - 1):
    n = min(lst[idx + 1] - lst[idx], n)
print(n)

Submission status: Wrong Answer

Solution code:
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[a[i+1]-a[i]for i in range(n-1)]
b.insert(0,a[0]-x)

def search_common_divisor(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def search_list_common_divisor(*numbers):
    b=[search_common_divisor(numbers[0],numbers[1])]
    for i in numbers:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]


if n!=1:
    print(search_list_common_divisor(*b))
else:
    print(b[0])

Submission status: Wrong Answer

Solution code:
import functools
import fractions

def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	x_list.sort()
	print(x_list)
	a=[abs(x_list[i]-x_list[i+1]) for i in range(n)]
	print(a)
	print(functools.reduce(fractions.gcd,a))

resolve()

Submission status: Wrong Answer

Solution code:
import functools
import fractions
def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	a=[i-j for i in x_list for j in x_list if i!=j]
	print(functools.reduce(fractions.gcd,a))

resolve()

Submission status: Wrong Answer

Solution code:
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(X)
x.sort()
s = [0 for i in range(n)]
for i in range(n):
  s[i] = x[i+1]-x[i]

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

ans = s[0]
for i in range(n-1):
  ans = gcd(ans, s[i])
print(ans)

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())
x = list(map(int, input().split())) + [X]
D = [0] * N

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

if N == 1:
    print(D[0])
    exit()

ans = gcd(D[0], D[1])
for j in range(2, N):
    ans = gcd(ans, D[i])

print(ans)

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())
x = list(map(int, input().split())) + [X]
D = [0] * N
ans = 0

for i in range(N):
    D[i] = abs(X - x[i])
    if i > 0:
        calc = gcd(num, D[i])
        if ans < calc:
            ans = calc
    else:
        num = gcd(0, D[i])

if ans > 0:
    print(ans)
else:
    print(D[0])

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = sorted(list(map(int, input().split())) + [X])
D = [0] * N

for i in range(1, N+1):
    D[i-1] = abs(x[i-1] - x[i])
    if len(D) > 1 and D[i-1] % 2 != 0:
        D.append(1)

print(min(D))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = sorted(list(map(int, input().split())) + [X])
D = [0] * N

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

print(min(D))

Submission status: Wrong Answer

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

for i in range(N):
    D.append(abs(X - x[i]))

print(min(D))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

answer = 0
for x in A:
  answer = gcd(answer, x)
print(answer)

Submission status: Wrong Answer

Solution code:
import fractions 
N,X=map(int,input().split())
L=list(map(int,input().split()))
LL=[abs(l-X) for l in L]
m=[fractions.gcd (LL[i],LL[i+1]) for i in range(N-1)]
if N==1:
  print(max(L)-N)
else:
  print(min(m))

Submission status: Wrong Answer

Solution code:
import math

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

for i in x:
    distance.append(abs(i-X))

Submission status: Wrong Answer

Solution code:
import math

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

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())
x = list(map(int,input().split()))

x.append(X)
x.sort()

D = []
for n in range(N-1):
    D.append(x[n+1]-x[n])
    
ans = 0
for d in D:
    ans = gcd(ans,d)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
ls = [int(i)-x for i in input().split()]

from fractions import gcd
from functools import reduce

def gdc_list(lis):
    return reduce(gcd,lis)

print(gdc_list(ls))

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(x-data[0]))
    exit()

dis.sort()
if n == 2:
    print(gcd(x,dis[0]))
    exit()
#distanceのGCD



for i in range(n-2):#n-2→n == 2 の時を考慮
    dis[i+1] = gcd(dis[i+1],dis[i])
    
print(dis[i+1])

Submission status: Wrong Answer

Solution code:
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(data[0]-x))
    exit()
dis.sort()
#distanceのGCD
ans = 0

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

for i in range(n-2):
    ans = gcd(dis[i+1],dis[i])
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(data[0]-x))
    exit()
dis.sort()
#distanceのGCD
ans = 0

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

for i in range(n-2):
    ans = gcd(dis[i],dis[i+1])
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(data[0]-x))
    exit()
#distanceのGCD
ans = 0

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

for i in range(n-2):
    ans = gcd(dis[i],dis[i+1])
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(*data)
    exit()
#distanceのGCD
ans = 0

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

for i in range(n-2):
    ans = gcd(dis[i],dis[i+1])
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)
#distanceの生成
for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(*data)
    exit()
#distanceのGCD
ans = 0
print(dis)
def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

for i in range(n-2):
    ans = gcd(dis[i],dis[i+1])
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def GCD(a,b):
  if a == 0 or b == 0: return max(a,b)
  else:
    gcd = 1
    while 1:
      if a%b == 0:
        gcd = b
        break
      else:
        r = a%b
        a = b
        b = r
    return gcd

def main():
  n,x = map(int,input().split())
  pos = list(map(int,input().split()))
  res = 1
  if n == 1:
    res = abs(pos[0] - 1)
  else:
    gcd = GCD(abs(pos[0] - x), abs(pos[1] - x))
    for i in range(2,n): gcd = GCD(gcd, abs(pos[i] - x))
    res = gcd
  
  print(res)

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

if N == 1:
    print(abs(N-X))
else:
    P = [0]*N
    P[0] = abs(min(L) - X)
    for i in range(1,N):
        P[i] = abs(L[i]-L[i-1])

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

    ans = gcd(P[0],P[1])

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

    print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd

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

x2 = map(lambda y: y-1, x)

print(reduce(gcd,x2))

Submission status: Wrong Answer

Solution code:
import fractions

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

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

else:
    diff = []

    for i in x:
        diff.append(abs(X - i))

    g = fractions.gcd(diff[0],diff[1])

    for i in range(1,len(diff)):
        g = fractions.gcd(g,diff[i])

    print(g)

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()
D = 1000000001
for ni in range(N-1):
    if x[ni+1] - x[ni] < D:
        D = x[ni+1] - x[ni]       
        
print(D)

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()
D = 1000000000
for ni in range(N-1):
    if x[ni+1] - x[ni] < D:
        D = x[ni+1] - x[ni]
for ni in range(N):
    if abs(x[ni] - X) < D:
        D = abs(x[ni] - X)

print(D)

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()
D = 1000000000
for ni in range(N):
    if x[ni+1] - x[ni] < D:
        D = x[ni+1] - x[ni]
print(D)

Submission status: Wrong Answer

Solution code:
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

if len(y) == 1:
    print(y[0])
else:
    answer = fractions.gcd(y[0],y[1])
    for i in range(2,N):
        answer = fractions.gcd(answer,y[i])
        print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
l = list(map(int, input().split()))
ans = []
for i in l:
    ans.append(abs(X-i))
print(min(ans))

Submission status: Wrong Answer

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

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

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

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)

Submission status: Wrong Answer

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

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

for i in range(n):
    s[i] = s[i] - x

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(abs(t))

Submission status: Wrong Answer

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

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

for i in range(n):
    s[i] = s[i] - x

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)

Submission status: Wrong Answer

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

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())
if N == 1:
    x =int(input())
    print(x - X)
else:
    x =list(map(int, input().split()))
    ans = gcd(abs(x[0] - X), abs(x[1] - X))
    if N == 2:
        print(ans)
    else:
        for i in range(2, N):
            ans = gcd(ans, abs(x[i] - X))
        print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

#相対位置
x_list = [x - X for x in x_list]

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

if N >= 3:
    space = [abs(x_list[i + 1] - x_list[i]) for i in range(N - 1)]
    print(reduce(gcd, space))
elif N == 2:
    space = x_list[1] - x_list[0]
    print(space)
elif N == 1:
    space = x_list[0]
    print(space)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a  = list(map(int, input().split()))
a.append(m)
a.sort()
b = set([a[i]-a[i-1] for i in range(1,n + 1)])
ans = min(b)
c = [bool(i % ans == 0) for i in b]
if all(c):
    print(ans)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a  = list(map(int, input().split()))
a.append(m)
a.sort()
b = set([a[i]-a[i-1] for i in range(1,n + 1)])
c = [bool(i % 2 == 0) for i in b]
if all(c):
    print(min(b))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a  = list(map(int, input().split()))
a.append(m)
a.sort()
print(min([a[i]-a[i-1] for i in range(1,n + 1)]))

Submission status: Wrong Answer

Solution code:
import fractions

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

if N != 1:
    A = [0]*(N-1)
    for i in range(N-1):
        A[i] = x[i+1]-x[i]

    a = A[0]
    for i in range(N-1):
        a = fractions.gcd(a,A[i])
    print(a)
else:
    print(x[1]-x[0])

Submission status: Wrong Answer

Solution code:
# ABC109C - Skip
n, x = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
lst.append(x)
lst = sorted(lst)
d = 10 ** 9
for i in range(n):
    d = min(d, lst[i + 1] - lst[i])
print(d)

Submission status: Wrong Answer

Solution code:
# ABC109C - Skip
n, x = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
d = 10 ** 9
for i in lst:
    d = min(d, abs(i - x))
print(d)

Submission status: Wrong Answer

Solution code:
#import math
import fractions as math

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

Submission status: Wrong Answer

Solution code:
import fractions as f
N,X = map(int,input().split())
x = [int(_) for _ in input().split()]
y = [x[i]-X for i in range(N)]
ans = 0
for i in range(N):
    ans = f.gcd(ans,y[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
N,X = map(int,input().split())
x_list = list(map(int,input().split()))
sa = []
x_list.sort()
for i in range(N-1):
    sa.append(x_list[i+1]-x_list[i])
gcd = 0
for i in range(len(sa)-1):
    gcd = max(gcd,fractions.gcd(sa[i],sa[i+1]))
if N == 1:
    print(x_list[0]-N)
else:
    print(gcd)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
y = []
flag = 1

for i in range(len(x)) : 
    y.append(abs(X -x[i]))

M = min(y)

for i in range(M, 0, -1) : 
    flag = 1
    for j in range(len(y)) : 
        if y[j] % M != 0 : 
            flag = 0
            break
    if flag == 1 : 
        break
    
print(M)

Submission status: Wrong Answer

Solution code:
# これ問題の意味がわかりにくくない？
import fractions
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
diff = [abs(i-M) for i in X]
max_gcd = diff[0]
for i in range(1, len(diff)):
  max_gcd = fractions.gcd(diff[1], max_gcd)
print(max_gcd)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.append(M)
X = sorted(X)
diff = [X[i+1]-X[i] for i in range(len(X)-1)]
max_gcd = diff[0]
for i in range(1, len(diff)):
  max_gcd = fractions.gcd(diff[1], max_gcd)
print(max_gcd)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.append(M)
X = sorted(X)
diff = [X[i+1]-X[i] for i in range(len(X)-1)]
if len(diff) < 2:
  print(diff[0])
else:
  max_gcd = diff[0]
  for i in range(1, len(diff)):
    max_gcd = fractions.gcd(diff[1], max_gcd)
  print(max_gcd)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

l = []
for xx in x:
    l.append(abs(xx - X))

ans = 1
for ll in l:
    ans = gcd(ans, ll)

print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
A = list(map(int, input().split())) + [X]

a = sorted(A)

ld = a[1] - a[0]

def yu(a, b):
	ma = max([a, b])
	mi = min([a, b])
	while (ma % mi):
		t = ma
		mi = ma % mi
		ma = t
	return mi

for n in range(2, N + 1):
	d = a[n] - a[n - 1]
	ld = max(ld, yu(ld, d))

print(ld)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y

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

t=[int(j)-x for j in input().split()]
ans=t.pop()
for i in t:
    ans=gcd(ans,i)

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y

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

t=[int(j)-x for j in input().split()]
ans=t.pop()
for i in t:
    ans=gcd(ans,i)

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if x%y==0:
        return y
    while x%y==0:
        x,y=y,x%y
    return y

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

t=[int(j)-x for j in input().split()]
ans=t.pop()
for i in t:
    ans=gcd(ans,i)

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if x%y==0:
        return y
    while x%y==0:
        x,y=y,x%y
    return y

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

t=[int(j)-x for j in input().split()]
ans=t.pop()-x
for i in t:
    ans=gcd(ans,i)

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))
ans = x[0] - X

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

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    if y>x:
        a=y
        y=x
        x=a
    a=1
    while a*y:
        a=x%y
        x=y
        y=a
    return x

a,b=map(int,input().split())
c=list(map(int,input().split()))
c.append(b)
c.sort()
for i in range(a):
    c[-1-i]-=c[-2-i]
c[0]=0
for i in range(a):
    b=gcd(c[i],c[i+1])
print(b)

Submission status: Wrong Answer

Solution code:
def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
sabun.sort()
flag = True
for i in range(len(sabun)):
    if not sabun[i] % sabun[0] == 0:
        flag = False
if flag:
    print(sabun[0])
else:
    print(1)

Submission status: Wrong Answer

Solution code:
def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
print(sorted(sabun)[0])

Submission status: Wrong Answer

Solution code:
def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
print(N, X, x)
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
print(sorted(sabun)[0])

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
lista = [int(i) for i in input().split()]
lista.append(x)
lista.sort()
def gcd(a,b):
    if a<b:
        a,b = b,a
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

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

print(ans)

Submission status: Wrong Answer

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

x.append(X)
x.sort()
a=x[0]
for i in range(1,len(x)):
    a=fractions.gcd(a,x[i])
print(a)

Submission status: Wrong Answer

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

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

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

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

ans = -1
temp = gcd(abs(X - x[1]), abs(X - x[0]))
for i in range(2, n):
    temp = gcd(temp, abs(X - x[i]))
    if ans < temp:
        ans = temp
print(ans)

Submission status: Wrong Answer

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

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

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

x.append(X)
x = list(set(x))
x.sort()

ans = float('inf')

for i in range(n-1):
    temp = x[i+1] - x[i]

    if ans > temp:
        ans = temp

print(ans)

Submission status: Wrong Answer

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

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

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

x.append(X)
x.sort()

ans = float('inf')

for i in range(n-1):
    temp = x[i+1] - x[i]

    if ans > temp:
        ans = temp

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

n,x = map(int,input().split())
x_l =[int(i) for i in input().split()]
x_l.append(x)
x_l=sorted(x_l)

diff=[]    
for i in range(n):
    diff.append(abs(x_l[i+1]-x_l[i]))

gcd_l=[0]
for i in range(n):
    gcd_l.append(gcd(gcd_l[i],abs(x_l[i+1]-x_l[i])))    
print(max(gcd_l))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

n,x = map(int,input().split())
x_l =[int(i) for i in input().split()]
x_l.append(x)
x_l=sorted(x_l)

gcd_l=[0]
for i in range(n):
    gcd_l.append(gcd(gcd_l[i],abs(x_l[i+1]-x_l[i])))    
print(max(gcd_l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

tmp = 0
for i in range(1, len(x)):
    tmp = f(x[i-1], x[i])

print(tmp)

Submission status: Wrong Answer

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

def algGCF(a,b):
  if a % b == 0:
    return b
  else:
    return algGCF(b,a%b)
GCF = abs(X-L[0])
for i in range(1,N):
  GCF = algGCF(GCF,X-L[i])
print(GCF)

Submission status: Wrong Answer

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


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
ans = [0]*(N-1)

for i in range(N-1):
    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
if ans:
    print(max(ans))
else:
    print(x[0] - X)