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):
import fractions
n,k=map(int,input().split())
a=list(map(int,input().split()))
if max(a)<k:
    print("IMPOSSIBLE")
    exit()
t=a[0]
if n!=1:
    for i in range(1,n):
        t=fractions.gcd(t,a[i])

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

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

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

if K in A:
    print('POSSIBLE')
    exit()

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

g = reduce(gcd, A)

if g == 1:
    print('POSSIBLE')
    exit()

for a in A:
    if K > a:
        continue
    if (a - K) % g == 0:
        print('POSSIBLE')
        break
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 A.count(K) != 0:
    print('POSSIBLE')
    exit()

g = reduce(gcd, A)
for a in A:
    if K > a:
        continue
    if (a - K) % g == 0:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

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

Solution (Python):
from fractions import gcd

n, k = map(int, input().split())
a = list(map(int, input().split()))
n = a[0]
max_num = max(a)
for num in a[1:]:
    n = gcd(n, num)
if k % n == 0 and k <= max_num:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
import fractions

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n, k = rm()
a = rl()
s = set()
b = a[0]
if k in set(a):
  print('POSSIBLE')
  exit()
if len(set(a)) == 1:
  if tuple(set(a))[0] == k:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  exit()
for i in a:
  g = fractions.gcd(i, b)
  if g == 1:
    print('POSSIBLE')
    exit()
  if k % g == 0 and k <= max(i, b):
    print('POSSIBLE')
    exit()
else:
  print('IMPOSSIBLE')

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    A.sort()

    g = A[0]

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (a - K) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

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

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (a - K) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

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



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

if k>a[-1]:
    print("IMPOSSIBLE")
    exit()

if a[0]==1:
    print("POSSIBLE")
    exit()

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

for item in a[1:]:
    if item%gg!=0:
        flag=1

if flag==1:
    print("POSSIBLE")
    exit()
else:
    if k%gg==0:
        print("POSSIBLE")
        exit()
    else:
        print("IMPOSSIBLE")
        exit()

Solution (Python):
import fractions

n, k = map(int, input().split())
L = list(map(int, input().split()))
if n == 1:
    g = L[0]
else:
    g = fractions.gcd(L[0], L[1])
    for i in range(2, n):
        g = fractions.gcd(g, L[i])
M = max(L)
if M >= k and k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

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

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (K - a) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

Solution (Python):
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
import sys
sys.setrecursionlimit(200000)
N,K = map(int,input().split())
A = list(map(int,input().split()))

def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
if N ==1:
    g = A[0]
else:
    g = gcd(A[0],A[1])
    for i in range(2,N):
        g = gcd(g,A[2])

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

Solution (Python):
import sys

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


max_a = max(A)
if K > max_a:
    print("IMPOSSIBLE")
    sys.exit()


A.sort()

diffs = set()
for i in range(N-1):
    diffs.add(A[i+1] - A[i])

if 1 in diffs:
    print("POSSIBLE")
    sys.exit()

for a_i in A:
    if a_i - K in diffs or a_i == K:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Solution (Python):
import fractions
n, k =map(int, input().split())
dat = list(map(int, input().split()))
x = dat[0]
for i in range(n):
    x = fractions.gcd(x, dat[i])

if k % x == 0 and k <= max(dat):
    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):
    ans = "IMPOSSIBLE"

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

    if (max(a) - k) % g == 0:
        ans = "POSSIBLE"
    else:
        ans = "IMPOSSIBLE"

print(ans)

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

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

if k in arr:
    print("POSSIBLE")
    sys.exit()

if k > max(arr):
    print("IMPOSSIBLE")
    sys.exit()

div = reduce(gcd, arr)

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

Solution (Python):
import fractions
N,K=map(int,input().split())
A=list(map(int,input().split()))
g=A[0]
for i in range(N):
  g=fractions.gcd(g,A[i])
flag=False
for i in range(N):
  if((A[i]-K)>=0 and (A[i]-K)%g==0):
    flag=True
if flag:
  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 a in A:
  g = gcd(g, a)

B = [a - K for a in A if a >= K]
for b in B:
  if b % g == 0:
    print('POSSIBLE')
    quit()

print('IMPOSSIBLE')

Solution (Python):
def f(a, b):
    if b:
        return f(b, a%b)
    return a

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

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

p = f(A[0], A[1])

for i in A[1:]:
    p = f(p, i)

print("POSSIBLE" if p==f(p, K) and K <= max(A) else "IMPOSSIBLE")

Solution (Python):
def f(a,b):
    if b:return f(b,a%b)
    return a
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print('POSSIBLE' if k==a[0] else 'IMPOSSIBLE')
    exit()
p=f(a[0],a[1])
for i in a[1:]:
    p=f(p,i)
print('POSSIBLE' if p==f(p,k) and k<=max(a) else 'IMPOSSIBLE')

Solution (Python):
N,K=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for i in A[1:]:
    g=gcd(g,i)
a=0
if A[0]%g!=K%g:
    a=1
if K>max(A):
    a=1
print(("IM" if a else "" )+"POSSIBLE")

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    
    import fractions
    from functools import reduce

    n, k = ns()
    a = na()

    gcdans = reduce(fractions.gcd, a)

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from fractions import gcd
n,k = map(int,input().split())
A = list(map(int,input().split()))
if k in A:
    print("POSSIBLE")
    sys.exit()
A.sort()
if A[n-1] < k:
    print("IMPOSSIBLE")
    sys.exit()
mod = A[0]
for i in range(1,n):
    mod = gcd(mod,A[i])
    if mod == 1 or (k%mod==0):
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

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

Solution (Python):
import numpy as np
n, k = map(int, input().split())

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


def gcd(a, b):
    larger = max(a, b)
    smaller = min(a, b)

    if larger % smaller == 0:
        return smaller
    else:
        return gcd(smaller, larger % smaller)


m = int(np.max(a))

g = None

for i in range(n):
    if g is None:
        g = gcd(a[i], a[i])
    else:
        g = gcd(a[i], g)

if k % g == 0 and k <= m:
    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 i in a[1:]:
    g = gcd(g,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()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

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

g = B[0]
for b in B[1:]:
    g = fractions.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import fractions
import functools

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, K = ZZ()
    A = ZZ()
    g = functools.reduce(fractions.gcd, A)
    print('POSSIBLE' if K <= max(A) and K%g == 0 else 'IMPOSSIBLE')
    return

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
import fractions as fr
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

ans = 0
x=a[0]
for i in range(1,n):
    x =fr.gcd(x,a[i])
    
if max(a)<k:
    print("IMPOSSIBLE")
elif k in a:
    print("POSSIBLE")
elif k%x == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

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

if K in A:
  print('POSSIBLE')
  exit()

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,K,*A = map(int,read().split())
g = reduce(gcd,A)
x = max(A)

bl = (K<=x) and (K%g==0)
ans = 'POSSIBLE' if bl else 'IMPOSSIBLE'
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, k = Is()
A = LI()
if max(A) < k:
    print('IMPOSSIBLE')
    exit()
g = reduce(gcd, A)
if k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = max(abs(As[1] - As[0]), 1)
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

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

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


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

m = max(a)

g = a[0]

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

if k > m:
    print("IMPOSSIBLE")
elif 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):
    r = 1
    while r!=0:
        r = a%b
        a = b
        b = r
    return a

if max(A)<k:
    print('IMPOSSIBLE')
    exit()

if max(A)==n or min(A)==1:
    print('POSSIBLE')
    exit()

ans = A[0]
for i in A:
    ans = gcd(ans,i)

if ans > 1:
    if gcd(ans,k)>1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

else:
    print('POSSIBLE')

Solution (Python):
from fractions import gcd
n,k,*a=map(int,open(0).read().split())
x=a[0]
if k>max(a):
  print('IMPOSSIBLE')
  exit()
for a_i in a:
  x=gcd(x,a_i)
if k%x==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Solution (Python):
import sys
sys.setrecursionlimit(2000000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
if N ==1:
    g = A[0]
else:
    g = gcd(A[0],A[1])
    if N > 2:
        for i in range(2,N):
            g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import fractions
from functools import reduce

N,K,*A = map(int,open(0).read().split())
g = reduce(fractions.gcd,A)
if max(A) < K:
    print("IMPOSSIBLE")
elif K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import functools
import fractions

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(fractions.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    A=LI()
    G = 0
    for a in A:
        G=gcd(a,G)
    if(max(A)>=K and K%G==0):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

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

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

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






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

Solution (Python):
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    if A[-1] < K:
        print('IMPOSSIBLE')
        return
    from fractions import gcd
    g = A[0]
    for i in range(1,N):
        g = gcd(g,A[i])
    if K % g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
main()

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

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

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

Solution (Python):
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
if k>max(a):
    print('IMPOSSIBLE')
    exit()

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

def gcd(num_list):
    ans = 0
    for i in num_list:
        ans = gcd_base(ans, i)
    return ans

if k%gcd(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()))
if max(A) < K:
    print("IMPOSSIBLE")
else:
    temp = A[0]
    for a in A[1:]:
        temp = gcd(a, temp)
    if K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res

import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

def main():
    n, k = MII()
    aa = MII()
    g = ft.reduce(gcd, aa)
    m = max(aa)
    if k <= m and k%g==0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Solution (Python):
def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()








def main():
    ma = max(A)
    if ma < K:
        return False
    if K in A:
        return True
    g = A[0]
    for a in A:
        g = gcd(g, a)
    for a in A:
        if (a-K) % g == 0:
            return True
    return False


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

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

def main():
    N, K = map( int, input().split())
    A = list( map( int, input().split()))
    A.sort()
    if A[-1] < K:
        print('IMPOSSIBLE')
        return
    g = A[0]
    if A[0] == K:
        print('POSSIBLE')
        return
    for i in range(N-1):
        if A[i+1] == K:
            print('POSSIBLE')
            return
        g = gcd(g, A[i+1]-A[i])
    if K < g:
        print('IMPOSSIBLE')
        return
    if K%g == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
if __name__ == '__main__':
    main()

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


if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    gcd_a=gcd(*A)
    if k%gcd_a==0 and max(A)>=k:
        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()))

gcd = reduce(fractions.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, *X = map(int, open(0).read().split())

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

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

N, K, *X = map(int, open(0).read().split())

d = reduce(gcd, X)
for i in range(N):
    if X[i] < K:
        continue
        
    if (X[i] - K) % d == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

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

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

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

if 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 max(a) < k:
    print("IMPOSSIBLE")
    exit()
f = a[0]
for i in range(n):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    f = fractions.gcd(f,a[i])
    
if k % f != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

A = list(map(int, input().split()))
import fractions
def list_gcd(X):
    t = max(X)
    for i in X:
        t = fractions.gcd(t, i)
    return t

if k in A or (k % list_gcd(A) == 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()))

gcd = a[0]

max_a = max(a)

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

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

Solution (Python):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
m = max(A)
if N == 1:
    if A[0] == K:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    if K > m:
        print('IMPOSSIBLE')
    else:
        gcd = xgcd(A[0],A[1])
        for i in range(2,N):
            gcd = xgcd(gcd,A[i])
            if gcd == 1:
                print('POSSIBLE')
                break
        else:
            if K % gcd == 0:
                print('POSSIBLE')
            else:
                print('IMPOSSIBLE')

Solution (Python):
from fractions import gcd
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
gcm = 10**9+7
for i in range(N-1):
    gcm = min(gcm, gcd(A[i], A[i+1]))
if N == 1:
    print('IMPOSSIBLE' if K != A[0] else 'POSSIBLE')
    exit()

print('POSSIBLE' if K % gcm == 0 and K <= A[0] else 'IMPOSSIBLE')

Solution (Python):
def possible(b):
    print('POSSIBLE' if b else 'IMPOSSIBLE')
    exit()

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

if k in A:
    possible(True)

if k > max(A):
    possible(False)

if n == 1:
    possible(False)

A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from fractions import *
g = D[0]
for d in D:
    g = gcd(g, d)

possible(k % g == 0)

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

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

Solution (Python):


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

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

MAX = max(nums)
GCD = nums[0]
for num in nums:
    GCD = gcd(GCD, num)

if k <= MAX and k % GCD == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Solution (Python):
import fractions
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[0]*n
if k>max(a):
    print("IMPOSSIBLE")
    exit()
g=a[0]
for i in range(1,n):
    g=fractions.gcd(g,a[i])
for i in range(n):
    b[i]=a[i]%g
if k%g in b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Solution (Python):
import fractions
from functools import reduce
N,K,*A = map(int,open(0).read().split())
g = reduce(fractions.gcd,A)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")

Solution (Python):
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    g = a[0]
    for i in range(1, n):
        g = fractions.gcd(g, a[i])
    if k <= max(a) and k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    return 0

if __name__ == "__main__":
    solve()