Problem:


Score : 300 points

Problem Statement

There is a box containing N balls. The i-th ball has the integer A_i written on it.
Snuke can perform the following operation any number of times:

Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.

Determine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9

1 \leq K \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

If it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.

Sample Input 1

3 7
9 3 4

Sample Output 1

POSSIBLE

First, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.
Next, take out 3 and 5, and return them back along with abs(3-5)=2.
Finally, take out 9 and 2, and return them back along with abs(9-2)=7.
Now we have 7 in the box, and the answer is therefore POSSIBLE.

Sample Input 2

3 5
6 9 3

Sample Output 2

IMPOSSIBLE

No matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.

Sample Input 3

4 11
11 3 7 15

Sample Output 3

POSSIBLE

The box already contains 11 before we do anything. The answer is therefore POSSIBLE.

Sample Input 4

5 12
10 2 8 6 4

Sample Output 4

IMPOSSIBLE



Sample input:
3 7
9 3 4


Sample output:
POSSIBLE

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_A = max(A)
A.sort()

if(max_A < K):
    print("IMPOSSIBLE")
else:
    num = 10**10
    for i in range(N-1):
        num = min(num, abs(A[i]-A[i+1]))

    for i in range(N):
        if(A[i] < K):
            continue
        if((K-A[i])%num == 0):
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
diff = 10 ** 9

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

if abs(A[0] - diff) > 0:
    diff = min(abs(A[0] - diff), diff)

can_make = False
for i in range(N):
    if A[i] % diff == K % diff and A[i] >= K:
        can_make = True

if can_make:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=soted(list(map(int,input().split())))
def gcd(x,y):
  if y==0:return x
  return gcd(y,x%y)
ans=""
s=0
for i in l:
  s=gcd(i,s)
  if s==1:break
else:
  if k%s!=l[-1]%s:
    ans="IM"
print(ans+"POSSIBLE")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=soted(map(int,input().split()))
def gcd(x,y):
  if y==0:return x
  return gcd(y,x%y)
ans=""
s=0
for i in l:
  s=gcd(i,s)
  if s==1:break
else:
  if k%s!=l[-1]%s:
    ans="IM"
print(ans+"POSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
A = sorted(map(int, input().split()))
INF = 10**5
diff = INF
for x, y in zip(A, A[1:]):
    diff = min(diff, abs(x-y))

MAX = A[-1]
ans = False
for a in A:
    if a-k < 0:
        continue
    x, r = divmod((a-k), diff)
    if r == 0:
        ans = True
        break
print("POSSIBLE" if ans else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions
N, K = map(int, input().split())
arr = list(map(int, input().split()))
t = fractions.gcd(arr[0],arr[1])
for i in range(1,N):
    t = fractions.gcd(t,arr[i])
if max(arr) < K or K % t != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Runtime Error

Solution code:
# Author: cr4zjh0bp
# Created: Mon Mar 23 15:10:04 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

import numpy as np

n, k = na()
a = np.array(na())

g = np.gcd.reduce(a)
m = np.amax(a)
if g == 1 and k <= m:
    print("Yes")
elif k % g == 0 and k <= m:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

n, k = map(int, input().split())
A = list(map(int, input().split()))

l = A.pop()
for a in A:
  l = gcd(l, a)

print('POSSIBLE' if k % l == 0 and max(A) >= k else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


N,K = map(int, input().split())
A = [int(i) for i in input().split()]
a = gcd(A)
cnt = max(A)
while cnt > K:
    cnt -= a
print('POSSIBLE' if cnt == K else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from math import gcd
import functools

def gcd_list(l):
    return functools.reduce(gcd, l)

def solve():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    d = gcd_list(A)
    ret = False
    if K > max(A):
        print('IMPOSSIBLE')
        return
    
    for a in A:
        if (a-K)%d == 0:
            ret = True
            break
            
    print('POSSIBLE' if ret else 'IMPOSSIBLE')
    
solve()

Submission status: Runtime Error

Solution code:
N, K = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()], reverse=True)

for v in A:
    if K==v:
        print("POSSIBLE")
        quit()
if K > A[0]:
    print("IMPOSSIBLE")
    quit()

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

for v in d:
    K %= v

if K:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

L = sorted(A)
while True:
    s = set()
    for i in range(len(L)-1):
        s.add(L[i+1]-L[i])
    L = list(s)
    L.sort()
    if L[0] == 1 or len(L) == 1:
        break

if K > max(A):
    ans = "IMPOSSIBLE"
elif K in A or L[0] == 1:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"
    for a in A:
        if a-K < 0:
            continue
        if (a-K)%L[0] == 0:
            ans = "POSSIBLE"
            break

print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

L = sorted(A)
s = set()
while len(s) != 1:
    for i in range(len(L)-1):
        s.add(L[i+1]-L[i])
    L = list(s)
    L.sort()
    if L[0] == 1:
        break

if K > max(A):
    ans = "IMPOSSIBLE"
elif K in A or L[0] == 1:
    ans = "POSSIBLE"
else:
    ans = "IMPOSSIBLE"
    for a in A:
        if a-K < 0:
            continue
        if (a-K)%L[0] == 0:
            ans = "POSSIBLE"
            break

print(ans)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))

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

gcd1 = gcd(a[0], a[1])

for i in range(2,n):
    gcd1 = gcd(gcd1,a[i])

if k > max(a):
    print('IMPOSSIBLE')
else:
    if k % gcd1 == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(n-1):
    if k == a[i]:
        print("POSSIBLE")
        break
    if k % (a[i+1] - a[i]) == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import functions
n,k = map(int,input().split())
a = sorted(list(map(int,input().split())))
a_max = max(a)
a_gcd = a[0]
for i in range(n):
  a_gcd = functions.gcd(a_gcd,a[i])
if k <= a_max and k % a_gcd == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse = True)

diff = [0] * (N - 1)

for i in range(N - 1):
  diff[i] = A[i] - A[i + 1]
  
if K > A[0]:
  print("IMPOSSIBLE")
elif len(set(diff)) == 1 and A[0] % diff[0] == 0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Submission status: Runtime Error

Solution code:
# A - Getting Difference
from fractions import gcd

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-1):
    if i==0:
        t=gcd(a[i],a[i+1])
        continue
    t=gcd(t,a[i+1])
if k%t!=0:
    print('IMPOSSIBLE')
    exit()

a_max=max(a)
b=a_max-k

if b<0:
    print('IMPOSSIBLE')
    exit()
elif b==0:
    print('POSSIBLE')
    exit()

even_count=0
odd_count=0

for aa in a:
    if aa%2==0:
        even_count+=1
    else:
        odd_count+=1
a.sort()
sa=[]
for i in range(n-1):
    if abs(a[i+1]-a[i])!=0:
        sa.append(abs(a[i+1]-a[i]))
sa.sort()


is_even=False
is_odd=False
for ssaa in sa:
    if ssaa%2==0:
        if ssaa<=b:
            is_even=True
    else:
        if ssaa<=b:
            is_odd=True

if is_even==True and is_odd==True:
    print('POSSIBLE')
elif is_even==True and is_odd==False:
    if odd_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
elif is_even==False and is_odd==True:
    if even_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# A - Getting Difference
from fractions import gcd

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-1):
    if i==0:
        t=gcd(a[i],a[i+1])
        continue
    t=gcd(t,a[i+1])
if k%t!=0:
    print('IMPOSSIBLE')
    exit()

a_max=max(a)
b=a_max-k

if b<0:
    print('IMPOSSIBLE')
    exit()
elif b==0:
    print('POSSIBLE')
    exit()

even_count=0
odd_count=0

for aa in a:
    if aa%2==0:
        even_count+=1
    else:
        odd_count+=1
a.sort()
sa=[]
for i in range(n-1):
    sa.append(abs(a[i+1]-a[i]))
sa.sort()


is_even=False
is_odd=False
for ssaa in sa:
    if ssaa%2==0:
        if ssaa<=b:
            is_even=True
    else:
        if ssaa<=b:
            is_odd=True

if is_even==True and is_odd==True:
    print('POSSIBLE')
elif is_even==True and is_odd==False:
    if odd_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
elif is_even==False and is_odd==True:
    if even_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# A - Getting Difference
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n-1):
    if i==0:
        t=gcd(a[i],a[i+1])
        continue
    t=gcd(t,a[i+1])
if k%t!=0:
    print('IMPOSSIBLE')
    exit()

a_max=max(a)
b=a_max-k

if b<0:
    print('IMPOSSIBLE')
    exit()

even_count=0
odd_count=0

for aa in a:
    if aa%2==0:
        even_count+=1
    else:
        odd_count+=1
a.sort()
sa=[]
for i in range(n-1):
    sa.append(abs(a[i+1]-a[i]))
sa.sort()


is_even=False
is_odd=False
for ssaa in sa:
    if ssaa%2==0:
        if ssaa<=b:
            is_even=True
    else:
        if ssaa<=b:
            is_odd=True

if is_even==True and is_odd==True:
    print('POSSIBLE')
elif is_even==True and is_odd==False:
    if odd_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
elif is_even==False and is_odd==True:
    if even_count>0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

from functools import reduce
from math import gcd

g = reduce(gcd, a)

print('POSSIBLE' if (k % g == 0) and (k <= sum(a)) else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))
if k > li[0]:
    print("IMPOSSIBLE")
    exit()
def gcd_all(list):
    return gcd_all([math.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
gcd = gcd_all(li)
if k%gcd != 0:
    print("IMPOSSIBLE")
    exit()
print("POSSIBLE")

Submission status: Runtime Error

Solution code:
import math
length, target = map(int, input().split(" "))
nums = sorted([int(n) for n in input().split(" ")])
minimum = min(nums)
odd, even, gcd = 0, 0, minimum
for n in nums:
    if n % 2 == 0:
        even = 1
    else:
        odd = 1
    gcd = math.gcd(gcd, n)
if target > max(nums):
    print("IMPOSSIBLE")
elif target in nums:
    print("POSSIBLE")
else:
    if gcd == 1:
        print("POSSIBLE")
    else:
        if target % gcd == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(2,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(2,n):
        tmp_gcd = fractions.gcd(gcd,a[i])
        if tmp_gcd < gcd:
            gcd = tmp_gcd
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

def gcd(a, b):
    while a:
        a, b = b, a % b
    return b
#solve
def solve():
    n, k = LI()
    a = LI()
    if k in a:
        print("POSSIBLE")
        return
    if max(a) < k:
        print("IMPOSSIBLE")
        return
    g = a[0]
    for ai in a:
        g = gcd(g, ai)
    if k % g != 0:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import sys
import copy
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def prime_factor(n):
    ans = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ans.append(i)
            n = n//i
    if n != 1:
        ans.append(n)
    return ans

def main():
	N, K = MAP()
	A = MAP()

	# max(A) < K の場合は達成不可
	# Aが全て偶数(2の倍数)でKが奇数の場合
	# Aが全てnの倍数でKがnの倍数でない場合

	if A.count(K) > 0:
		print('POSSIBLE')
	elif max(A) < K:
		print('IMPOSSIBLE')
	else:
		factors = list(set(prime_factor(A[0])))
		for i in range(1, N):
			tmp = copy.deepcopy(factors)
			for j in range(len(factors)):
				# print(i, j, factors)
				if A[i]%factors[j]:
					tmp.pop(j)
			factors = copy.deepcopy(tmp)
			if len(factors) == 0:
				print('POSSIBLE')
				sys.exit()
		for f in factors:
			if K % f != 0:
				print('IMPOSSIBLE')
				sys.exit()
			else:
				K %= f
		else:
			print('POSSIBLE')

if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))

ans = 'IMPOSSIBLE'
if max(A) >= K:
    from math import gcd
    from functools import reduce
    g = reduce(gcd,A)
    if K % g == 0: ans = 'POSSIBLE'

print(ans)

Submission status: Runtime Error

Solution code:

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

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

A.sort()

if A[-1] < K:
    print("IMPOSSIBLE")
    exit()

if K in A or 1 in A:
    print("POSSIBLE")
    exit()

def gcd(a,b):
    x = max([a,b])
    y = min([a,b])
    while y:
        x, y = y, x % y
    return x

g = A[0]
for i in range(1,N):
    g = gcd(A[i], g)
    

print("POSSIBLE" ig K % g == 9 else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
g = a[0]
for i in range(n):
    g = math.gcd(g, a[i])
if k % g == 0 and k <= a[-1]:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def gcd(l, r):
  while r != 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = abs(A[1] - A[0])
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if (K % g) == (A[0] % g) and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def gcd(l, r):
  while r != 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if (K % g) == (A[0] % g) and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if K % g == A[0] % g and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, A[i+1] - A[i])
  if K % g == A[0] % g and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

if max(a) < k:
    print('IMPOSSIBLE')
elif k in a:
    print('POSSIBLE')
else:
    for i in a:
        if i %2 == 0:
            flag_e = True
        else:
            flag_o = True
    if flag_e is True and flag_o is True:
        for i in a:
            if i == min(a):
                continue
            else:
                if i %2 == 0:
                    if (i-min(a)) % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
                else:
                    if i % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
        print('IMPOSSIBLE')
        exit()
    elif flag_e is True:
        if k %2 == 0:
            print('POSSIBLE')
            exit()
        else:
            print('IMPOSSIBLE')
            exit()
    else:
        for i in a:
            if i == min(a):
                continue
            else:
                if i % min(a) != 0:
                    print('POSSIBLE')
                    exit()
                else:
                    continue
        print('IMPOSSIBLE')
        exit()

Submission status: Runtime Error

Solution code:
N,K = map(int(input().split()))
A = list(map(int,input().split())))
g = A[0]
import fractions
for i in range(1,N):
    g = fractions.gcd(g,A[i])
if K % g == 0:
    if K <= M:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,k=map(int,input().split())
g=0
m=0
for a in map(int,input().split()):
  	m=max(m,a)
    g=gcd(g,a)

print("POSSIBLE" if(k%g==0 and k<=m) else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,k=map(int,input().split())
g=0
for a in map(int,input().split()):
    if(k==a):
        print("POSSIBLE")
        return
    g=gcd(g,a)

print("POSSIBLE" if(k%g==0) else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

M = max(A)
G = gcd(A[0], A[1])
for i in range(2, N):
    G = gcd(G, A[i])
# print(M, G)

if K <= M and K % G == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

if K in A:
    print("POSSIBLE")
    exit(0)

An = A.copy()
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        aij = abs(A[i] - A[j])
        if aij not in An:
            An.append(aij)

if K in A:
    print("POSSIBLE")
    exit(0)

while A != An:
    A = An.copy()
    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            aij = abs(A[i] - A[j])
            if aij not in An:
                An.append(aij)

    # print(A)
    # print(An)

    if K in A:
        print("POSSIBLE")
        exit(0)

if K in An:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str


def solve(N: int, K: int, A: "List[int]"):
    if K in A:
        print(YES)
        return
    
    if max(A) < K:
        print(NO)
        return
    
    ## 互いに素のものが一つでもあれば1が作れるからなんでも作れる→互いにそのものがあるか判定
    from math import fractions
    from functools import reduce
    def gcd_list(numbers):
        return reduce(fractions.gcd, numbers)
    
    if gcd_list(A) == 1:
        print(YES)
    else:
        if K%gcd_list(A) == 0:
            print(YES)
        else:
            print(NO)

    return


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
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
gcd = gcd_list(A)

if K > max(A):
    print("IMPOSSIBLE")
elif K % gcd !=0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Runtime Error

Solution code:
#from fractions import gcd
from functools import reduce
from math import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k > max(a):
    print('IMPOSSIBLE')
    exit(0)
if k in a:
    print('POSSIBLE')
    exit(0)


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


if k % gcds(*a) == 0:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

if k in cv:
    print("POSSIBLE")
    exit()

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

if n==1:
    if a[0]==k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()
    
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

if k in cv:
    print("POSSIBLE")
    exit()

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

if n==1:
    if a[0]==k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

Submission status: Runtime Error

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

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

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

c = fractions.gcd(*a)

for i in a:
  if i - k > 0 and (i-k) % c == 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))

b = []

for i in range(len(a) - 1):
  b.append(abs(a[i]-a[i+1]))
  
c = int(np.min(b))

for i in a:
  if abs(i-k) % c == 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))

b = []

for i in range(len(a) - 1):
  b.append(abs(a[i]-a[i+1]))
  
c = np.min(b)

for i in a:
  if abs(i-k) % c == 0:
    print("POSIIBLE")
    sys.exit()
    
print("IMPOSIIBLE")

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
s=A[1]-A[0]
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd


def gcd_list(A):
    num=A[0]
    for i in A:
        num=gcd(num,i)
    return num


n,k=map(int,input().split())
A=list(map(int,input().split()))
print("POSSIBLE" if k%gcd_list(A)==0 and k<=max(A) else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


def gcd_list(A):
    return reduce(math.gcd,A)


n,k=map(int,input().split())
A=list(map(int,input().split()))
print("POSSIBLE" if k%gcd_list(A)==0 and k<=max(A) else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
if K > maxA:
	print("IMPOSSIBLE")
	sys.exit()

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

for i in range(1,N):
	if i == 1:
		temp = GCD(A[0],A[1])
	else:
		temp = GCD(temp, A[i])

if temp == 1:
	ans = "POSSIBLE"
else:
	if K//temp == 0:
		ans = "POSSIBLE"
	else:
		ans = "IMPOSSIBLE"

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import fractions
    def gcd(li):
        fractions.reduce(fractions.gcd, li)

    n, k, *a = map(int, open(0).read().split())
    g = gcd(a)
    if max(a)>=k and k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  c = min(c, a[i+1]-a[i])
  if c == 1:
    break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  c = min(c, a[i+1]-a[i])
  if c == 1:
    break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

agcd = gcd(*a)

if max(a) > k and k%agcd ==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
import fractions

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

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

A.sort()

for i in range(N-1):

    if i == 0:
        now = fractions.gcd(A[0],A[1])

    else:
        now = fractions.gcd(now,A[i+1])

if K % now == 0 and K <= A[-1]:
    print ("POSSIBLE")
else:
    print ("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
g=l[0]
max=l[0]
for i in range(1,1+n-1):
  g=gcd(g,l[i])
  if max<l[i]:
    max=l[i]
if max<k:
  print("POSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
ans=""
if max(A)<k:
  ans="IMPOSSIBLE"
elif k in A:
  ans="POSSIBLE"
else:
  g=gcd(A[0], A[1])
  for i in range(2,n):
    g=gcd(g,A[i])
  if g!=0 and k%g==0:
    ans="POSSIBLE"
  else:
    ans="IMPOSSIBLE"
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
import functools
#from functools import reduce
import math
#from math import gcd

gcda=functools.reduce(math.gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
from functools import reduce
from math import gcd

gcda=functools.reduce(gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for a in A[1:]:
    g=gcd(g,a)
print(['IMPOSSIBLE','POSSIBLE'][(g==1 or K%g==0) and max(A)>=K]

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for a in A[1:]:
    g=gcd(g,a)
print(['IMPOSSIBLE','POSSIBLE'][((g==1 or K%g==0) and max(A)>=K)