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

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


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


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


for i in range(N):
    if A[i] == K:
        print('POSSIBLE')
        exit()
    elif A[i] > K and (A[i] - K) % g == 0:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Solution (Python):
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

from functools import reduce
from fractions import gcd

if K <= max(A) and K % reduce(gcd, A) == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

from fractions import gcd
from functools import reduce

if max(A) < K:
    print("IMPOSSIBLE")
    quit()

g = reduce(gcd, A)
for a in A:
    if gcd(a, K) == g:
        print("POSSIBLE")
        quit()

print("IMPOSSIBLE")

Solution (Python):
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while b > 0:
        a, b = b, a % b
    return a

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0] * (n+1)
for i in range(n):
    b[i+1] = gcd(b[i], a[i])
if (k <= max(a)) & (k >= min(a)):
    if k % b[-1] == 0:
        ans = "POSSIBLE"
    else:
        ans = "IMPOSSIBLE"
else:
    ans = "IMPOSSIBLE"
print(ans)

Solution (Python):
from fractions import gcd
from functools import reduce

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

if n == 1:
    print("POSSIBLE" if k == a[0] else "IMPOSSIBLE")
else:
    g = reduce(gcd, a)
    print("POSSIBLE" if k % g == 0 and k <= max(a) else "IMPOSSIBLE")

Solution (Python):
import fractions
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
g=A[0]
for i in range(1,n):
  g=fractions.gcd(g,A[i])
print("POSSIBLE" if k%g==0 and k<=max(A) else "IMPOSSIBLE")

Solution (Python):
n,k = map(int,input().split())
A = list(map(int,input().split()))
from fractions import gcd
if max(A) < k:
    print("IMPOSSIBLE")
else:
    g = A[0]
    for a in A:
        g = gcd(a,g)
    if k%g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n,k=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  if k==arr[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  g=gcd(arr[0],arr[1])
  flag=False
  for i in range(n):
    g=gcd(g,arr[i])
  arr=sorted(arr,reverse=True)
  for i in range(n):
    if k>arr[i]:
      break
    if (arr[i]-k)%g==0:
      flag=True
  if flag:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

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

from functools import reduce
from fractions import gcd

g = reduce(gcd, A, A[0])

if K%g==0 and K<=max(A):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Solution (Python):
inf = 10**10
import sys
input = sys.stdin.readline
from functools import reduce
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def gcd_list(numbers):
    return reduce(gcd,numbers)
def lcm(a,b):
  return a*b //gcd(a,b)
n,k = map(int,input().split())
a = list(map(int,input().split()))
d = gcd_list(a)
if k > max(a):
    print("IMPOSSIBLE")
else:
    if (max(a)-k)%d == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
from functools import reduce
def gcd(a,b):
  if a<b:a,b=b,a
  if a%b==0:return b
  return gcd(b,a%b)
 
read=lambda :map(int,input().split())
n,k=read()
*a,=read()
 
m=max(a)
o=reduce(gcd,a)
print("POSSIBLE" if k<=m and k%o==0 else "IMPOSSIBLE")

Solution (Python):
from fractions import gcd

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

max_num = max(As)
prev = As[0]
for i in range(1, len(As)):
    prev = gcd(prev, As[i])

if K % prev == 0 and K <= max_num:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
n, k = map(int, input().split())
alist = list(sorted(map(int, input().split())))

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

if n == 1:
  if k == alist[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Solution (Python):
from functools import reduce
N,K = map(int,input().split())
A = list(map(int,input().split()))
M = max(A)
def gcd(a, b): 
    while b:
        a, b = b, a % b
    return a
m = reduce(gcd,A)
if K <= M and K % m == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

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

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

print("POSSIBLE" if K%g==0 and K<=max(A) else "IMPOSSIBLE")

Solution (Python):
import sys
from fractions import gcd
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
if max(A)<K:
    print('IMPOSSIBLE')
    sys.exit()
if max(A)==K:
    print('POSSIBLE')
    sys.exit()
if N==1:
    print('IMPOSSIBLE')
    sys.exit()
A=sorted(A,reverse=True)
B=A[1:]
b=B[0]
for i in range(1,len(B)):
    b=gcd(b,B[i])
if (max(A)-K)%b==0:
    print('POSSIBLE')
    sys.exit()
print('IMPOSSIBLE')

Solution (Python):
import fractions as fr
from functools import reduce
def gcd(a):
  return reduce(fr.gcd, a)
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = gcd(a)
print("POSSIBLE" if (k in a) or (max(a) >= k and (g == 1 or k%g == 0)) else "IMPOSSIBLE")

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

def gcd(a,b):
    if a%b==0:
        return(b)
    else:
        return(gcd(b,a%b))
    
gcd_num = A[0]
for a in A:
    gcd_num = gcd(a,gcd_num)
    
if K%gcd_num==0 and K<=max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
from functools import reduce
from fractions import gcd
n, k = map(int, input().split())
a = list(map(int, input().split()))
print('POSSIBLE' if k % reduce(gcd, a) == 0 and max(a) >= k else 'IMPOSSIBLE')

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
if max(a)<k:
    print('IMPOSSIBLE')
else:
    g = a[0]
    for i in range(n):
        g = gcd(max(g,a[i]),min(g,a[i]))
    if k%g==0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Solution (Python):
from functools import reduce


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


N, K = map(int, input().split())
A = list(map(int, input().split()))
g = reduce(gcd, A)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")

Solution (Python):
from functools import reduce


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

  
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
max_A = max(lst_A)
gcd_A = reduce(gcd, lst_A)

ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

print(ans)

Solution (Python):
from functools import reduce
import fractions



def gcd_lst(lst):
    return reduce(fractions.gcd, lst)
    

    
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
max_A = max(lst_A)
gcd_A = gcd_lst(lst_A)

ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

print(ans)

Solution (Python):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
pos = "POSSIBLE"
imp = "IMPOSSIBLE"

if max(A) < K:
  print(imp)
  exit()

for i in range(1, N):
  a = A[i - 1]
  b = A[i]
  while a != b:
    if a < b:
      b -= (b // a) * a
      if b == 0:
        b = a
    else:
      a -= (a // b) * b
      if a == 0:
        a = b
  A[i - 1] = a
  A[i] = b

if K % A[-1] == 0:
  print(pos)
else:
  print(imp)

Solution (Python):
import fractions
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) >= K:
    for i, a in enumerate(A):
        if i == 0:
            gcd = a
            continue
        gcd = fractions.gcd(gcd, a)
    if K % gcd == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

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


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

g = a[0]
for aa in a:
    g = gcd(g, aa)

d = (max(a) - K)
if d >= 0:
    if d % g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

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


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

g = a[0]
for aa in a:
    g = gcd(g, aa)

d = (max(a) - K)
if d >= 0:
    if d % g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def gcd(a,b):
  if a%b != 0:
    return gcd(b,a%b)
  else:
    return b
cur = A[0]
for i in range(N):
  cur = gcd(A[i],cur)
if max(A) < K:
  print('IMPOSSIBLE')
else:
  if K%cur != 0:
    print('IMPOSSIBLE')
  else:
    print('POSSIBLE')

Solution (Python):
from functools import reduce
from fractions import gcd
N,K=map(int,input().split())
A=sorted(map(int,input().split()))
M=reduce(gcd,A)
if K<=A[-1] and K%M==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

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

if N == 1:
	x = A[0]
else:
	a = A[0]
	for i in range(N - 1):
		b = A[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	x = a

if K % x == 0 and max(A) >= K:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Solution (Python):
import sys
input = sys.stdin.readline
from functools import reduce
from fractions import gcd
def gcd_list(numbers):
    return reduce(gcd, numbers)
n,k = map(int,input().split())
A = list(map(int,input().split()))
if k % gcd_list(A) == 0 and k <= max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))
if K in A:
    print('POSSIBLE')
    exit()
if max(A) < K:
    print('IMPOSSIBLE')
    exit()

from fractions import gcd
g = A[0]
for a in A[1:]:
    g = gcd(g,a)
print('POSSIBLE' if K%g==0 else 'IMPOSSIBLE')

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

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

num = a[0]
for i in range(1, n):
    num = gcd(num, a[i])

if k > max(a):
    print("IMPOSSIBLE")
    exit()

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

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


N, K = map(int, input().split())
A = list(map(int, input().split()))
G = A[0]
for a in A:
    G = gcd(a, G)
print('POSSIBLE' if K % G == 0 and K <= max(A) else 'IMPOSSIBLE')

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

def gcd_list(a):
    x = a[0]
    for i in range(len(a)):
        x = gcd(a[i], x)
    return x
        

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

ans = 'IMPOSSIBLE'
A.sort()
if A[-1] >= k and (A[-1] - k) % gcd_list(A) == 0:
    ans = 'POSSIBLE'

print(ans)

Solution (Python):
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
  
def solve():
  n,k= (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  ans = 'IMPOSSIBLE'
  if max(a) < k :
    return ans
  elif k in a:
    ans = 'POSSIBLE'
    return ans
  else:
    gcd = gcd_list(a)
    
    if gcd == 1 or k%gcd == 0 :ans ='POSSIBLE'
    return ans
       
  
  
  return ans
if __name__ == '__main__':
  print(solve())

Solution (Python):
n, k = map(int, input().split())
A = [int(i) for i in input().split()]

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

B = [0] * (n - 1)
for i in range(n - 1):
    B[i] = gcd(A[i], A[i + 1])
    
if k > max(A):
    print('IMPOSSIBLE')
elif k in A:
    print('POSSIBLE')
elif k % B[-1] == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

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

if K in A:
    print("POSSIBLE")
    exit(0)
if K > max(A) or N == 1:
    print("IMPOSSIBLE")
    exit(0)

g = 1000000000
for k in range(1,N):
    g = min(g,gcd(A[k-1],A[k]))

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

Solution (Python):
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());print("IM"*(0!=k%F.reduce(f.gcd,a)or max(a)<k)+"POSSIBLE")

Solution (Python):
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());print("IM"*(0!=k%F.reduce(f.gcd,a)or max(a)<k)+"POSSIBLE")

Solution (Python):
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());
P="POSSIBLE"

if max(a)<k:
    print("IM"+P)
elif k%F.reduce(f.gcd,a)!=0:
    print("IM"+P)
else:
    print(P)

Solution (Python):
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());
P="POSSIBLE"

if max(a)<k:
    print("IM"+P)
else:
    if k%F.reduce(f.gcd,a)!=0:
        print("IM"+P)
    else:
        print(P)

Solution (Python):
from functools import reduce
from fractions import gcd
n,k,*a=map(int,open(0).read().split())
if max(a)<k:
    print("IMPOSSIBLE")
elif max(a)==k:
    print("POSSIBLE")
else:
    if k%reduce(gcd,a)==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
N, K = map(int, input().split())
L = list(map(int, input().split()))

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

flag = False
for i in range(N):
    if L[i] >= K:
        flag = True
        
if flag:
    g = L[0]
    for i in range(N):
        g = gcd(g, L[i])
        
    if gcd(g, K) == g:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    
else:
    print('IMPOSSIBLE')

Solution (Python):
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N,K = IL()

if N == 1:
    if K == I():
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    l = IL()
    l.sort(reverse=True)

    if K <= l[0]:
        num = gcd(l[0],l[1])
        for i in l:
            if i%num == 0:
                continue
            else:
                num = gcd(num,i)
        if K%num == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd
from functools import reduce

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

GCD = reduce(gcd, a)

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

Solution (Python):
from functools import reduce
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k>max(a):
    print("IMPOSSIBLE")
    exit()
if k%reduce(gcd,a)==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
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
if k in a:
    print("POSSIBLE")
elif k>max(a):
    print("IMPOSSIBLE")
else:
    x=a[0]
    for i in range(1,n):
        x=gcd(x,a[i])
    if k%x==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
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
if k in a:
    print("POSSIBLE")
elif k>max(a):
    print("IMPOSSIBLE")
else:
    x=a[0]
    for i in range(1,n):
        x=gcd(x,a[i])
    if k%x==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd
from functools import reduce

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


N,K = map(int,input().split())
A = list(map(int,input().split()))
gcd = gcd_list(A)
if K % gcd == 0 and K <= max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd
n,k = map(int, input().split())
aa = list(map(int, input().split()))

gcd_aa = aa[0]
for a in aa[1:]:
    gcd_aa = gcd(gcd_aa, a)

print('POSSIBLE' if k<=max(aa) and k%gcd_aa==0 else 'IMPOSSIBLE')

Solution (Python):
N,K = (int(i) for i in input().split())
li = [int(i) for i in input().split()]

max = max(li)

b = min(li)
for a in li:
    while True:
        if a%b == 0:
            break
        tb = b
        b = a%b
        a = tb

if K <= max:
    if K%b == max%b:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Solution (Python):



def main():
    from fractions import gcd

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    max_a = max(a)
    max_gcd = a[0]

    for i in range(n - 1):
        max_gcd = min(max_gcd, gcd(a[i], a[i + 1]))

    if k <= max_a and k % max_gcd == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Solution (Python):
N,K= map(int, input().split())
x = list(map(int, input().split()))
x = list(set(x))
x.sort()
t = max(x)
y = x[0]
s = [1000000000000]
o=0
if x[0] == K:o=1
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
    if x[i] == K:o = 1
s.sort()
m = min(y,s[0])
if (t>= K and K%m==0) or o==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
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()))
g = A[0]
for a in A:
    g = gcd(g, a)
if k <= max(A) and k%g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
N,K=map(int,input().split())

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

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

for i in range(N):
    Num=gcd(Num,A[i])
    
if K%Num==0:
    if K>max(A):
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd

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

m = A[0]
for a in A[1:]:
    m = gcd(a, m)

print("IM"*(K>max(A) or K%m != 0)+"POSSIBLE")

Solution (Python):
from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a, b):
    while a != 0:
        a,b=b%a,a
    return b
def lcm(x, y):
    return (x * y)//gcd(x, y)
t=reduce(gcd,a)
if t==1:
    if max(a)>=k:
        print('POSSIBLE')
        exit()
else:
    if k in a:
        print('POSSIBLE')
        exit()
    if k%t==0 and max(a)>=k:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Solution (Python):
import fractions
def gcd_all(a):
    A = a[0]
    length = len(a)
    for i in range(1,length):
        A = fractions.gcd(A,a[i])
    return A

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

a.sort()
if k > a[n-1]:
    print('IMPOSSIBLE')
    exit()
A = gcd_all(a)
if k%A == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
def factor(N):
    ret = []
    i = 2
    while N > 1:
        if N % i == 0:
            ret.append(i)
            N //= i
        else:
            i += 1
    return ret


assert (factor(4) == [2, 2])
assert (factor(2) == [2])
assert (factor(3) == [3])
assert (factor(10) == [2, 5])

from collections import Counter


def solve(N, K, As):
    if K > max(As):
        return "IMPOSSIBLE"
    iter = Counter(factor(min(As)))
    for a in As:
        for k, v in iter.items():
            if a % k != 0:
                iter[k] = 0
            else:
                count = 0
                kk = k
                while a % kk == 0:
                    kk *= k
                    count += 1
                iter[k] = min(v, count)

    if all([v == 0 for v in iter.values()]):
        return "POSSIBLE"
    else:
        d = 1
        for k, v in iter.items():
            if v != 0:
                d *= k ** v
        if K % d == 0:
            return "POSSIBLE"
    return "IMPOSSIBLE"


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))

Solution (Python):
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=max(a)
p=a[0]
for i in range(1,n):
    p=gcd(a[0],a[i])
print("POSSIBLE" if k%p==0 and k<=c else "IMPOSSIBLE")

Solution (Python):
from functools import reduce

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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


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

ans = "IMPOSSIBLE"
if max(A) < K:
    print(ans)
    exit()
if K in A:
    ans = "POSSIBLE"
else:
    gcd = reduce(gcd, A)
    if K % gcd == 0:
        ans = "POSSIBLE"
print(ans)

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

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

m=max(a)
g=a[0]
for i in range(n):
    g=gcd(g,a[i])
if k%g==0 and k<=m:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN =LIST()


if max(aN) < K:
    print('IMPOSSIBLE')
    exit()


base = gcd_list(aN)
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN =LIST()


if max(aN) < K:
    print('IMPOSSIBLE')
    exit()


base = aN[0]
for i in range(1, N):
    base = gcd(base, aN[i])
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
def gcd(x, y):
    if y == 0:
        return x
    if x < y:
        return gcd(y, x)
    return gcd(y, x % y)


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

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

ma = max(a)
ok = (K <= ma and (ma - K) % g == 0)

print('POSSIBLE' if ok else 'IMPOSSIBLE')

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))
def f(l, s):
    return s if l % s == 0 else f(s, l % s)

z = f(max(a), min(a))
for i in a:
    z = f(i, z)
if max(a) >= k and k % z == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

def f(l, s):
    return s if l % s == 0 else f(s, l % s)

z = f(max(a), min(a))
for i in a:
    z = f(i, z)
if max(a) >= k and k % z == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

def f(l, s):
    return s if l % s == 0 else f(s, l % s)

z = f(a[-1], a[0])
for i in a:
    z = f(i, z)
if a[-1] >= k and k % z == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)

def gojoho(l, s):
    return s if l % s == 0 else gojoho(s, l % s)

koubaisu = gojoho(a[1], a[0])
for i in a:
    koubaisu = gojoho(i, koubaisu)

if k % koubaisu == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
lena = len(seta)
sorteda = sorted(seta)
mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
for i in range(1, len(sorteda)):
    seta.add(sorteda[i] % mini)

sorteda = sorted(seta)

mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]

if k % mini == 0:
    print('POSSIBLE')
    sys.exit(0)
print('IMPOSSIBLE')

Solution (Python):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
change = True
lena = 0
while lena != len(seta):
    change = False
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        seta.add(sorteda[i] % mini)
    lena = len(seta)

mini = sorted(seta)[1]
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Solution (Python):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
change = True
while change:
    change = False
    setb = seta.copy()
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        setb.add(sorteda[i] % mini)
    if len(setb) != len(seta):
        change = True
        seta = setb

mini = sorted(seta)[1]
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Solution (Python):
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))


a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
change = True
while change:
    change = False
    setb = seta.copy()
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        setb.add(sorteda[i] % mini)
    if setb != seta:
        change = True
        seta = setb

mini = sorted(seta)[1]
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Solution (Python):


import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


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


N, K = LI()
A = LI()
if max(A) < K:
    print('IMPOSSIBLE')
    exit()

g = A[0]
for a in A: g = gcd(g, a)

print('POSSIBLE' if K % g == 0 else 'IMPOSSIBLE')

Solution (Python):
N,K = map(int,input().split())
arr = [int(i) for i in input().split()]
maxnum = max(arr)
def gcd(x,y):
    if x%y == 0:
        return y
    else:
        return gcd(y,x%y)

ok = False
num = gcd(max(arr[0:2]),min(arr[0:2]))
for i in arr[2:]:
    if num < i:
        num = gcd(i,num)
    else:
        num = gcd(num,i)

if K <= maxnum and (K-maxnum)%num == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
def gcd(x,y):
  if x<y:
    x,y=y,x
  if y==0:
    return x
  return gcd(y,x%y)

N,K=map(int,input().split())
A=[int(i) for i in input().split()]
G=A[0]
for i in range(1,N):
  G=gcd(G,A[i])
if max(A)>=K and K%G==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
  return reduce(gcd, numbers)
n,k = map(int, input().split())
a = list(map(int, input().split()))
if k % gcd_list(a) != 0 or max(a) < k:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")