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):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")



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


def solve(N, K, A_list):
    A_list = list(sorted(A_list))
    if max(A_list) < K:
        return False

    if K in A_list:
        return True

    x = A_list[0]
    min_d = INF
    for a in A_list:
        min_d = min(min_d, gcd(a, x))

    for a in A_list:
        if a > K and (a - K) % min_d == 0:
            return True
    return False


def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))

    print("POSSIBLE" if solve(N, K, A_list) else "IMPOSSIBLE")


if __name__ == '__main__':
    main()

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

def solve():
    n, k = list(map(int, input().strip().split()))
    a = list(map(int, input().strip().split()))

    m = a[0]
    maxx = a[0]
    for i in range(1, n):
        m = gcd(m, a[i])
        if a[i] > maxx:
            maxx = a[i]

    if k % m == 0 and k <= maxx:
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

print(solve())

Solution (Python):
"""
    Author        : Arif Ahmad
    Date          :
    Algo          :
    Difficulty    :
"""
from sys import stdin, stdout
from fractions import gcd


def main():
    n, k = [int(_) for _ in stdin.readline().strip().split()]
    a = [int(_) for _ in stdin.readline().strip().split()]

    g = a[0]
    for x in range(1, n):
        g = gcd(g, a[x])

    if k % g == 0 and k <= max(a):
        stdout.write('POSSIBLE\n')
    else:
        stdout.write('IMPOSSIBLE\n')


if __name__ == '__main__':
    main()

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

def gcd(n,m):
    if n < m:
        tmp = n
        n = m
        m = tmp
    while n % m != 0:
        tmp = m
        m = n % m
        n = tmp
    return m
g = M
for a in A:
    g = gcd(g,a)
    if g == 1:
        break
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):


from fractions import gcd
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
g=a[0]
for i in xrange(n):
 g=gcd(g,a[i])
if k<=max(a) and k%g==0:
 print 'POSSIBLE'
else:
 print 'IMPOSSIBLE'

Solution (Python):
from fractions import gcd

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

if K > max(A):
  print('IMPOSSIBLE')
  exit()

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

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

Solution (Python):
n, k = map(int, raw_input().split())
arr = map(int, raw_input().split())

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

cur = arr[0]
for x in arr:
    cur = gcd(cur, x)

if k % cur == 0 and k <= max(arr):
    print "POSSIBLE"
else:
    print "IMPOSSIBLE"

Solution (Python):
from fractions import gcd
 
 
def get_difference():
	
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"
 
 
if __name__ == "__main__":
	get_difference()

Solution (Python):
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))
 
M = max(A)
G = reduce(gcd, sorted(A))
 
if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Solution (Python):
from fractions import gcd

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

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

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

Solution (Python):
import fractions

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

if n==1:
    ans=a[0]
elif n==2:
    ans=fractions.gcd(a[0],a[1])

else:
    ans=fractions.gcd(a[0],a[1])
    for i in range(2,n):
        ans=fractions.gcd(ans,a[i])

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

Solution (Python):
N,K=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
def gcd(a,b):
    a,b=min(a,b),max(a,b)
    if b%a==0:
        return a
    else:
        return gcd(a,b%a)

def findgcd(A):
    ans=gcd(A[0],A[-1])
    for i in range(len(A)):
        ans=gcd(ans,A[i])
        if ans==1:
            return 1
    return ans
ans=findgcd(A)
good=0
if N>1:
    for i in range(len(A)):
        if A[i]==K:
            good=1
            break
        elif A[i]>K:
            if (A[i]-K)%ans==0:
                good=1
                break
else:
    if A[0]==K:
        good=1
if good==1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import fractions 
length,target = (int(n) for n in raw_input().split(" "))
ball = [int(n) for n in raw_input().split(" ")]
gcd = ball[0]
for i in range(1,length):
    gcd = fractions.gcd(gcd,ball[i])
if target % gcd == 0 and target <= max(ball):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
m = max(l)
for i in range(1,n):
    l[i] = gcd(max(l[i],l[i-1]),min(l[i],l[i-1]))
if k%l[-1] == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n,k = rli()
A = rli()

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

b = 0
for a in A:
    b  = gcd(a, b)

if k%b or k > max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

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

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

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

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

n,k = map(int, raw_input().split())
l = map(int, raw_input().split())
g = l[0]
idx = 1
while idx < n:
    g = gcd(g,l[idx])
    idx += 1
if k <= max(l) and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Solution (Python):
import functools as ft

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

def main():
	N, K = list(map(int, input().split()))
	nums = list(map(int, input().split()))

	max_num = max(nums)
	g = ft.reduce(lambda x, y: gcd(x, y), nums)

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

if __name__ == '__main__':
	main()

Solution (Python):
def gcd(u, v):
    while v:
        u, v = v, u % v
    return u

N, K = [int(x) for x in input().split()]
A    = [int(x) for x in input().split()]

g = 0
for i in A:
    g = gcd(i, g)

if K % g or K > max(A):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Solution (Python):
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))

M = max(A)
G = reduce(gcd, sorted(A))

if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

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

def gcd_list(lst):
    g = lst[0]
    for i in range(1,len(lst)):
        g = gcd(g,lst[i])
    return g
    
n, k = (int(i) for i in input().split())
a = list(int(i) for i in input().split())  

maxA=max(a)

if (k <= maxA and k%gcd_list(a) == 0) or (k in a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


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

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM

print(ans)

Solution (Python):
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


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

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

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

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)

Solution (Python):
def gcd(a, b) :
    if a < b :
        a,b = 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 = a[0]
for i in range(n-1) :
    g = gcd(g,a[i+1])

if (k < max(a) and k%g == 0) or (k in a) :
    print('POSSIBLE')
else :
    print('IMPOSSIBLE')

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

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

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

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

Solution (Python):
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

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

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    input_raw = list(read_func().strip().split())
    A = set([])
    for i in range(len(input_raw)):
        A.add(int(input_raw[i]))
    A_list = list(A)
    possible_flag = False
    is_all_geometric = False

    if len(filter(lambda x:x >=K , A)) != 0:
        g = A_list[0]
        for i in range(1, len(A_list)):
            x = A_list[i]
            if x == K:
                possible_flag = True
                break
            g = gcd(g, A_list[i])

        if g == 1:
            possible_flag = True
        elif K % g == 0 :
            possible_flag = True

    if possible_flag == True:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import fractions
N,K=map(int,input().split())
A=sorted(list(set(map(int,input().split()))))
N=len(A)
if N==1:
  print("POSSIBLE" if A[0] == K else "IMPOSSIBLE")
  sys.exit(0)
g=A[1]-A[0]
for i in range(1,len(A)-1):
  g = fractions.gcd(A[i+1]-A[i], g)
if K <= A[N-1] and (K-A[0]) % g == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
import fractions

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))


n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
else:
    g = a[0]
    for i in a[1:]:
        g = fractions.gcd(g, i)
    if(k % g == 0):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
from sys import stdin
from fractions import gcd
n, k = map(int, stdin.readline().split())
a = map(int, stdin.readline().split())
g = a[0]
for x in a:
    g = gcd(g, x)
m = max(a)
if k > m or (m - k) % g:
    print "IMPOSSIBLE"
else:
    print "POSSIBLE"

Solution (Python):
import random
import fractions

def solve(N, K, A):
    gcd = A[0]
    for x in A:
        gcd = fractions.gcd(gcd, x)
    if K % gcd == 0 and max(A) >= K:
        return 'POSSIBLE'
    else:
        return 'IMPOSSIBLE'

def solve2(N, K, A):
    mx = max(A)
    B = [False] * (mx + 1)
    for i in A:
        B[i] = True
    while True:
        update = False
        for i in range(mx + 1):
            if not B[i]:
                continue
            for j in range(i + 1, mx + 1):
                if not B[j]:
                    continue
                d = abs(i - j)
                if not B[d]:
                    update = True
                    B[d] = True
        if not update:
            break
    return 'POSSIBLE' if K <= mx and B[K] else 'IMPOSSIBLE'











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

Solution (Python):


def primefactor(n):
    r = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            r += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : r += [n]
    return r

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

p = set(primefactor(min(A)))

for i in A:
    p = set([x for x in p if i % x == 0])
    if len(p) == 0 : break

if (K < max(A) and (len(p) == 0 or all(K % x == 0 for x in p))) or K in A:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
def gcd(_a, _b):
    if _b == 0:
        return _a
    return gcd(_b, _a % _b)


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    if max(A) < K:
        print("IMPOSSIBLE")
    elif K in A:
        print("POSSIBLE")
    else:
        tmp = -1
        min_value = min(A)
        for i in range(0, N):
            tmp = gcd(min_value, A[i])
            if tmp == 1:
                break
        if tmp == 1:
            print("POSSIBLE")
        elif K % tmp == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

Solution (Python):

from fractions import gcd


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


if K > A[-1]:
    print('IMPOSSIBLE')
else:
    flag = True
    tmp = reduce(gcd, A)
    if tmp != 1:
        flag = False
    for a in A:
        if a == K or (K - a) % tmp == 0:
            flag = True
            break
    if flag:
        print("POSSIBLE")
    else:
        print('IMPOSSIBLE')

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

def s(n):
    ret = []
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            ret.append(i)
        i += 1
    if n > 1:
        ret.append(n)
    return ret

def j(N, K, a):
    flag = 1
    if K > max(a):
        flag = 0
    else:
        minE = min(a)
        eles = s(minE)
        ce = []
        for e in eles:
            boolA = [ea % e == 0 for ea in a]
            if all(boolA):
                a = [ea // e for ea in a]
                ce.append(e)
        for e in ce:
            if K % e != 0:
                flag = 0
                break
            else:
                K //= e
    print(('IMPOSSIBLE', 'POSSIBLE')[flag])

j(N, K, a)

Solution (Python):

N, A = map(int, input().split())
tmp = input()
ary = [int(a) for a in tmp.split()]

maximum = max(ary)


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


g = None
for a in ary:
    if g is None:
        g = a
        continue
    g = gcd(g, a)

if A % g == 0 and A <= maximum:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

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

ans = False

A = sorted(A)

key = 99999999999999
    
if A[-1] < K:
    ans = False

else:
    for i in range(2, A[0]+1):
        key_flag = True
        for a in A:
            if a % i !=0:
                key_flag = False
                break
                
        if key_flag == True:
            key = i
            break

    if key_flag == False:
        ans = True

    elif K % key == 0:
        ans = True

    else:

        ans = False           
    
if ans == True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):

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


def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x = y
        y = r

    return x


LCM = A_list[0]
for i in range(1, N):
    LCM = gcd(LCM, A_list[i])
    
if K % LCM == 0 and K <= max(A_list):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):



def solve(k, bs):
    if k > max(bs):
        return False
    cs = set(bs)
    for b in cs:
        if abs(b - k) == 0 or abs(b - k) in cs:
            return True
    return False


def main():
    _, k = [int(x) for x in input().split()]
    bs = [int(x) for x in input().split()]
    print("POSSIBLE" if solve(k, bs) else "IMPOSSIBLE")


if __name__ == '__main__':
    main()

Solution (Python):

from fractions import gcd


def solve(k, aa):
    if k in aa:
        return True
    if k > max(aa):
        return False
    g = aa.pop()
    for a in aa:
        g = gcd(g, a)
        if g == 1:
            return True
    return k % g == 0


n, k = map(int, input().split())
aa = set(map(int, input().split()))
print('POSSIBLE' if solve(k, aa) else 'IMPOSSIBLE')

Solution (Python):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
 
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
if k in a:
  print "POSSIBLE"
else:
  c=a[:]
  while len(a)!=1:
    b=a.pop()
    a[0]=gcd(a[0],b)
  print "POSSIBLE" if k%a[0]==0 and max(c)>=k else "IMPOSSIBLE"

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

max_a = max(a)
min_a = min(a)

if K > max_a:
    print('IMPOSSIBLE')
else:
    is_found = False
    while (not is_found):
        is_found = True
        for i, a_i in enumerate(a):
            m = a[i] % min_a
            if m != 0:
                a[i] = m
                is_found = False
        min_a = min(a)
    if K % min_a == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Solution (Python):
n,k = map(int, raw_input().split())
aa = map(int, raw_input().split())

max_a = aa[0]

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

b = aa[0]
for i in range(1,n):
  a = aa[i]
  max_a = max(a, max_a)

  a,b = max(a,b), min(a,b)
  while a % b != 0:
    if a > b:
      a %= b
    else:
      b %= a
    a,b = max(a,b), min(a,b)

if k > max_a:
  print 'IMPOSSIBLE'
elif k % b == 0:
  print 'POSSIBLE'
else:
  print 'IMPOSSIBLE'

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

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

def main():
    N,K = LI()
    a = LI()
    if max(a) < K:
        return 'IMPOSSIBLE'
    if K in a:
        return 'POSSIBLE'
    t = a[0]
    for c in a[1:]:
        t = gcd(c, t)
        if t <= 1:
            return 'POSSIBLE'
    for c in a:
        if (c > K) and (((c-K) % t) == 0):
            return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())

Solution (Python):
import fractions

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

ans = "IMPOSSIBLE"

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

for ai in a:
    if k <= ai and (ai - k) % d == 0:
        ans = "POSSIBLE"
        break
print(ans)

Solution (Python):
from fractions import gcd
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
min_A, max_A = min(A), max(A)
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
if max_A < K:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE" if K % g == 0 else "IMPOSSIBLE")

Solution (Python):
import fractions

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

def solve(N, K, As):
    if N == 1:
        if K == As[0]:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return
    g = As[-1]
    for a in As[:-1]:
        g = fractions.gcd(g, a)
    maxA = max(As)
    if (maxA >= K) and ((maxA - K)%g) == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

solve(N, K, As)

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


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


def solve():
    n, k = read_int_list()
    a = read_int_list()
    if k > max(a):
        return 'IMPOSSIBLE'
    g = a[0]
    for i in range(n):
        g = gcd(g, a[i])
        if k % g == 0:
            return 'POSSIBLE'
    return 'IMPOSSIBLE'


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

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

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


if len(As) == 1:
    if K == As[0]:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:        
    for i in range(len(As)-1):
        diff = As[i+1] - As[i]
        if i == 0:
            unit = diff
        else:
            unit = gcd(unit, diff)
    
    ok = False
    for a in As:
        if (a - K) % unit == 0 and K <= a:
            ok = True
    
    if ok:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

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

m = max(A)
if m < K:
	print("IMPOSSIBLE")
else:
	gcd = A[0]
	for i in range(1,N):
		gcd = fractions.gcd(A[0], A[i])
	if fractions.gcd(gcd, K) == gcd:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")

Solution (Python):
import sys
N,K=map(int, input().split())
A=list(map(int, input().split())) 
A.sort(reverse=1)
m=A[0]
for i in range(N-1):
  if A[i]!=A[i+1]:
    m=min(m,A[i]-A[i+1])

n=K%m
if K>A[0]:
  print("IMPOSSIBLE")
  sys.exit()
for i in range(N):
  if A[i]%m==n:
    print("POSSIBLE")
    sys.exit()

print("IMPOSSIBLE")

Solution (Python):
from fractions import gcd


def main():
    n, k = [int(x) for x in raw_input().split()]
    a = [int(x) for x in raw_input().split()]
    if k > max(a):
        return False
    g = a[0]
    for ai in a[1:]:
        g = gcd(g, ai)
    return k % g == 0


if __name__ == '__main__':
    print("POSSIBLE" if main() else "IMPOSSIBLE")

Solution (Python):
from fractions import gcd

yes = "POSSIBLE"
no = "IMPOSSIBLE"

N, K = map(int, raw_input().split())
A = map(int, raw_input().split())

if N == 1:
    print yes if A[0] == K else no
    exit()

if K > max(A):
    print no
    exit()

g = reduce(gcd, A)
if g == 1:
    print yes
elif K % g == 0:
    print yes
else:
    print no

Solution (Python):

import sys

input=sys.stdin.readline

def gcd(u,v):
    while v:
        u,v=v,u%v
    return u

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

g=0
for i in a:
    g=gcd(i,g)

if k%g or k>max(a): print("IMPOSSIBLE")
else: print("POSSIBLE")