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 fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

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

Solution (Python):
from fractions import gcd

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

g = max(a)

if k > g:
    print("IMPOSSIBLE")
    exit()

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

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

Solution (Python):
from functools import reduce
def gcd(a, b):
    while b: a, b = b, a % b
    return a
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
g = reduce(gcd, A)
print("IMPOSSIBLE" if K%g or K > max(A) else "POSSIBLE")

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


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

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

Solution (Python):
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.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")

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

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

def solve() :
    x = A[0]

    for a in A[1:] :
        x = gcd(x, a)
        
    for a in A :
        if a >= K and (a - K) % x == 0 :
            return 'POSSIBLE'
            
    return 'IMPOSSIBLE'
    
print(solve())

Solution (Python):
from fractions 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")

Solution (Python):
from fractions 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")

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

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

if MAX >= K and (MAX-K)%GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

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

m = max(a)

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

b = a[0]
for x in a[1:]:
    b = gcd(b, x)

if k % b == 0 and k <= m:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

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

def main():
    n, q = list(map(int, input().strip().split()))
    v = list(map(int, input().strip().split()))
    v.sort()
    k = v[0]
    for i in range(1, n):
        k = gcd(v[i], k)
    if q <= v[-1] and q % k == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
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()
A = LIST()

max_a = max(A)
gcd_num = A[0]
for i in A:
	gcd_num = gcd(gcd_num, i)

if K in A or (K <= max_a and K % gcd_num == 0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Solution (Python):

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

def gcd(a, b):
    if a < b:
        a, b = b, a

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

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

if max(A) >= K and K % g == 0:
    print('POSSIBLE')
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()))

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')

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

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

if MAX >= K and (MAX-K)%GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
if k in a:
    print('POSSIBLE')
    quit()
if k > max(a):
    print('IMPOSSIBLE')
    quit()
if 1 in a:
    print('POSSIBLE')
    quit()
tmp = a[0]
for i in range(1,n):
    tmp = fractions.gcd(tmp,a[i])
if k%tmp == 0: 
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
if k in a:
    print('POSSIBLE')
    quit()
if k > max(a):
    print('IMPOSSIBLE')
    quit()
if 1 in a:
    print('POSSIBLE')
    quit()
a.sort()
tmp = a[1] - a[0]
for i in range(1,n-1):
    tmp = fractions.gcd(a[i+1]-a[i], tmp)
    if tmp == 1:
        break
tmp = fractions.gcd(tmp,a[0])
if tmp == 1 or k%tmp == 0: 
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


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

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


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

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

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

g = reduce(gcd, A)
ok = False
for a in A:
    if a == K:
        ok = True
    if a > K:
        ok |= (a - K) % g == 0
if ok:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
b=gcd(*a)
if max(a)-k>=0 and (max(a)-k)%b==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
import numpy as np
import sys
import math
from functools import reduce
import fractions as fr

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

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

c = int(gcd(*a))

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

Solution (Python):
import collections
import fractions
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
S=collections.Counter([A[i+1]-A[0] for i in range(N-1)])
gcd=S[0]
for s in S:
    gcd=fractions.gcd(gcd,s)


if K%gcd==A[0]%gcd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

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

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


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")

Solution (Python):

import fractions
import functools

def gcd_list(num_list):
    return functools.reduce(fractions.gcd, num_list)

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
if K in A:
    print("POSSIBLE")
    exit()

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


tmp = gcd_list(A)
if tmp == 1 or K % tmp == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import sys

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

if K in A:
	print("POSSIBLE")
	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 K % temp == 0:
	ans = "POSSIBLE"
else:
	ans = "IMPOSSIBLE"
print(ans)

Solution (Python):
def main():
    import fractions, functools
    def gcd(li):
        return functools.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()

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

def gcd(x, y):
    
    x, y = sorted([x, y])
    while x != 0:
        x, y = y%x, x
    return 1 if y == 0 else y
g = a[0]
for i in range(n):
    g = gcd(g, a[i])
if k <= m and k%g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from functools import reduce

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

g = reduce(gcd, A)
if K % g == 0:
    flag = True
else:
    flag = False
if max(A) < K:
    flag = False    

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

Solution (Python):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  if a[i] == a[i+1]:
    continue
  else:
    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")

Solution (Python):
from fractions import gcd


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

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

    mx = max(a)

    if k > mx:
        bl = False

    else:
        if k % g == 0:
            bl = True
        else:
            bl = False

    print("POSSIBLE" if bl else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):
from fractions import gcd


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

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

    mx = max(a)

    if k > mx:
        bl = False

    else:
        if (k - mx) % g == 0:
            bl = True
        else:
            bl = False

    print("POSSIBLE" if bl else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):
def solve(k, a):
    def gcd(a: int, b: int) -> int:
        if b == 0:
            return a
        else:
            return gcd(b, a % b)

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

    df = max(a) - k
    return (df >= 0) and (df % g == 0)


if __name__ == '__main__':
    _, k = map(int, input().split())
    a = tuple(map(int, input().split()))
    print('POSSIBLE' if solve(k, a) else 'IMPOSSIBLE')

Solution (Python):
from functools import reduce
from fractions import gcd
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Solution (Python):





mod=10**9+7
def swap(a,b):
    c=a
    a=b
    b=c
    return a,b
def factorial(x): 
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): 
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): 
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    
    
    
    
    
    
    
    
    
    
    n,k = map(int,input().split()) 
    a = list(map(int,input().split()))
    x=a[0]
    for i in range(n-1):
        x=gcd(x,a[i+1])
        if x==1:
            break
    if k in a:
        print("POSSIBLE")
        return
    if x==1 and k<=max(a):
        print("POSSIBLE")
        return
    for i in range(n):
        a[i]-=k
        if a[i]<=0:
            a[i]=-1
        if a[i]%x==0:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
main()

Solution (Python):
from fractions import*
n,k = map(int,input().split())
an = [int(i) for i in input().split()]
g = an[0]
for i in an[1:]:
  g = gcd(g,i)
if k > max(an) or k%g > 0:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

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


g = A[-1]
for i in A[:-1]:
    g = gcd(g, i)

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

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

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

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

agcd = gcdd(*a)

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

Solution (Python):
import fractions
n,k=map(int,input().split())
l=list(map(int,input().split()))
g=0
for i in l:
    g=fractions.gcd(g,i)
if k%g!=0 or max(l)<k:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Solution (Python):
import fractions
import sys

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

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

A.sort()

if len(A) == 1:
    if A[0] == K:
        print ("POSSIBLE")
    else:
        print ("IMPOSSIBLE")
    sys.exit()

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")

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

if A[-1]<K:
  print("IMPOSSIBLE")
  exit()
  
g=A[0]
for i in range(1,N):
  g=gcd(g,A[i])
  
if (A[-1]-K)%g==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Solution (Python):
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  if n>m:
    a=n
    b=m
  else:
    a=m
    b=n
  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("IMPOSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

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

Solution (Python):


import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    if k > a[-1]:
        print("IMPOSSIBLE")
    else:
        gcd = 0
        import fractions
        for i in range(n):
            gcd = fractions.gcd(a[i], gcd)
        for i in range(n):
            if a[i] >= k:
                if (a[i] - k) % gcd == 0:
                    print("POSSIBLE")
                    exit()
        print("IMPOSSIBLE")


if __name__ == '__main__':
    slove()

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

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

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



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

Solution (Python):
from fractions import gcd
N, K = map(int, input().split())
a = list(map(int, input().split()))
t = 0
if max(a) < K:
  print("IMPOSSIBLE")
  exit(0)
for i in range(N):
  t = gcd(t, a[i])
if K % t:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Solution (Python):

import copy

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

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    if k in w_list:
        return True, w_list
    w_list = sorted(list(set(w_list)))
    ww_list = set([w + K for w in w_list])
    if ww_list & set(w_list):
        return True, w_list
    else:
        return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            
            
            break
        if w_list == org_w_list:
            
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)

Solution (Python):

import copy

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

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        ww_list = set([w + K for w in w_list])
        if ww_list & set(w_list):
            return True, w_list
        else:
            return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)

Solution (Python):
import fractions
from functools import reduce

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

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

G = gcd(*A)
M = max(A)

if K % G == 0 and M >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from fractions 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)

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

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

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

if k%check==0 and k<=a[-1]:
    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()
g = A[0]
for i in range(1,N):
  g = gcd(g,A[i])
m = (K-min(A))/g
print('POSSIBLE' if m.is_integer() else 'IMPOSSIBLE')

Solution (Python):
from fractions import gcd

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

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)

Solution (Python):
from fractions import gcd


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

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==1:
        ans="POSSIBLE"

    elif g!=0 and K%g==0:
        ans="POSSIBLE"

    else:
        ans="IMPOSSIBLE"

print(ans)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
kk=a[0]
import fractions
for i in range(n-1):
	kk=fractions.gcd(kk,a[i+1])
if kk==1 and max(a)>=k:
	print("POSSIBLE")
elif k%kk!=0 or max(a)<k:
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")

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

Solution (Python):
from fractions import gcd;from functools import reduce;N,K,*A=map(int,open(0).read().split());print("IM"*(((K-A[0])%reduce(gcd,A)>0)|(K>max(A)))+"POSSIBLE")

Solution (Python):
from fractions import gcd
from functools import reduce
N,K,*A=map(int,open(0).read().split())
print("IM"*(((K-A[0])%reduce(gcd,A)>0)|(min(A)>K)|(K>max(A)))+"POSSIBLE")

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

import fractions


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

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

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

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

if K in A:
  print("POSSIBLE")
else:
  if max(A)<K:
    print("IMPOSSIBLE")
  else:
    max_gcd=A[0]
    for i in range(N):
      max_gcd=gcd(max_gcd,A[i])
    
    if (max(A)-K)%max_gcd==0:
      print("POSSIBLE")
    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()))
g = reduce(gcd, a)

print("POSSIBLE" if not k % g and k <= max(a) else "IMPOSSIBLE")

Solution (Python):


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
 
 
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)
 
div = a[0]
for i in range(1, n):
    div = gcd(div, a[i])
 
if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

Solution (Python):
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])

Solution (Python):


from fractions import gcd
from functools import reduce

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

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

Solution (Python):
from fractions import gcd
import functools

N, K = map(int,input().split())
A = list(map(int, input().split()))
max_A = max(A)
gcd_A = functools.reduce(gcd, A)
 
ans = 'POSSIBLE' if K <= max_A and K % gcd_A == 0 else 'IMPOSSIBLE'
 
print(ans)

Solution (Python):

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


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


next = A_N[0]
for i in range(len(A_N)):
    next = gcd(A_N[i], next)

if K > max(A_N):
    print('IMPOSSIBLE')
elif next == 1:
    print('POSSIBLE')
elif K % next ==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):

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


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


next = A_N[0]
for i in range(len(A_N)):
    next = gcd(A_N[i], next)

if K > max(A_N):
    print('IMPOSSIBLE')
elif next == 1:
    print('POSSIBLE')
elif K % next ==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):

from fractions import gcd
from functools import reduce


def main():
    N, K, *A = map(int, open(0).read().split())
    G, M = reduce(gcd, A), max(A)  
    flg = K <= M and K % G == 0
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
import fractions
from functools import reduce
N,K = map(int,input().split())
A = list(map(int,input().split()))
if max(A) < K:
  print("IMPOSSIBLE")
elif N == 1:
  if A[0] == K:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")
else:
  G = fractions.gcd(A[0],A[1])
  for g in range(2,N):
    G = fractions.gcd(G,A[g])
  if K % G != 0:
    print("IMPOSSIBLE")
  else:
    print("POSSIBLE")

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

def gcd_l(l):
    return reduce(gcd, l)

N, K = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = gcd_l(A)
if K % ans == 0 and max(A) >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
elif n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

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

    if gcda == 1 or k % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
N, K = map(int, input().split())
As = list(map(int, input().split()))
def calcgcd(a, b):
  if a > b:
    a, b = b, a
  while a > 0:
    a, b = b%a, a
  return b
gcd = 0
for A in As:
  gcd = calcgcd(gcd, A)
if K%gcd == 0 and K <= max(As):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

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

Solution (Python):
import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>=K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')