Problem:


Score : 300 points

Problem Statement

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

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

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

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9

1 \leq K \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

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

Sample Input 1

3 7
9 3 4

Sample Output 1

POSSIBLE

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

Sample Input 2

3 5
6 9 3

Sample Output 2

IMPOSSIBLE

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

Sample Input 3

4 11
11 3 7 15

Sample Output 3

POSSIBLE

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

Sample Input 4

5 12
10 2 8 6 4

Sample Output 4

IMPOSSIBLE



Sample input:
3 7
9 3 4


Sample output:
POSSIBLE

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
from functools import reduce
# python template for atcoder1
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

# Kがでかいのは論外
if max(aN) < K:
    print('IMPOSSIBLE')
    exit()

# aN全部の最大公約数を取る
base = gcd_list(aN)
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

# Kがでかいのは論外
if max(aN) < K:
    print('IMPOSSIBLE')
    exit()

# aN全部の最大公約数を取る
base = aN[0]
for i in range(1, N):
    base = gcd(base, aN[i])
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# coding:utf-8

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

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

tmp = inputs[0]
if K in inputs:
    print('POSSIBLE')
elif max(inputs) < K:
    print('IMPOSSIBLE')
else:
    if N == 1:
        if K == inputs[0]:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')
    else:
        for i in range(1, N):
            tmp = gcd(tmp, inputs[i])
        if tmp == 1:
            print('POSSIBLE')
        else:
            if (max(inputs) - K) % tmp == 0:
                print('POSSIBLE')
            else:
                print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
def euclid(x,y):
    a = max(x,y)
    b = min(x,y)
    
    r =  a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b


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

if N == 1:
    if K == A[0]:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
else:
    
    M = max(A)
    G = euclid(A[0],A[1])
    for i in range(1,N):
        G = euclid(A[i],G)
    
    if K % G == 0 and K <= M:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
    
print(ans)

Submission status: Accepted

Solution code:
import fractions
N,K=map(int,raw_input().split())
A=map(int,raw_input().split())

for i in range(N):
	if i==0:
		pass
	elif i==1:
		g=fractions.gcd( A[0] , A[1] )
	else:
		g=fractions.gcd( g , A[i] )

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

Submission status: Accepted

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

a.sort()

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


if a[len(a)-1]<K:
    print("IMPOSSIBLE")
else:
    now = a[0]
    for i in range(len(a)-1):
        now = gcd(a[i+1], now)
    if K%now == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import functools
import fractions
N,K = map(int,input().split())
A = list(map(int,input().split()))
gcd = functools.reduce(fractions.gcd,A)
max_A = max(A)
if K % gcd == 0 and K <= max_A:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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


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


g = A[0]
for a in A:
    g = gcd(g, a)
if K <= max(A) and K % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

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

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

S_possible = "POSSIBLE"
S_impossible = "IMPOSSIBLE"

b = 0

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

if K % b or K > max(A):
    print(S_impossible)
else:
    print(S_possible)

Submission status: Accepted

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

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

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

S_possible = "POSSIBLE"
S_impossible = "IMPOSSIBLE"

if N == 1:
    if K == A[0]:
        print(S_possible)
    else:
        print(S_impossible)
else:
    gcd_max = gcd(A[0], A[1])
    for i in range(N-1):
        gcd_current = gcd(A[i], A[i+1])
        if gcd_current < gcd_max:
            gcd_max = gcd_current
    if K % gcd_max == 0 and K <= max(A):
        print(S_possible)
    else:
        print(S_impossible)

Submission status: Accepted

Solution code:
from fractions import gcd

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

M = max(A)
while len(A)>1:# Aすべてのgcd
    a1 = A.pop()
    a2 = A.pop()
    A.append(gcd(a1, a2))
G = A[0]
if K%G==0 and K<=M:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
# import math
# import fractions
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")

Submission status: Accepted

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]

N, K = inpl()
A = inpl()
gcda = A[0]
for i in A:
    gcda = gcd(i, gcda)
if not K%gcda and max(A) >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def gcd(x: int, y: int) -> int:
    while y != 0:
        x = x % y
        x, y = y, x
    return abs(x)


def main() -> None:
    n, k = [next_int() for _ in range(2)]
    g, m = [0 for _ in range(2)]

    for i in range(n):
        a = next_int()
        if i == 0:
            g = a
            m = a
        g = gcd(g, a)
        m = max(m, a)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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 n==1:
  x=a[0]
else:
  x=gcd(a[0],a[1])
  for i in range(2,n):
    x=gcd(x,a[i])

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
a = list(map(int, input().split()))

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

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

Submission status: Accepted

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

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

Im = 'IMPOSSIBLE'
Po = 'POSSIBLE'

if max(A) < K:
    print(Im)
else:
    for i in range(N):
        if i == 0:
            tmp = gcd(A[i], 0)
        else:
            tmp = gcd(A[i],tmp)
        if tmp == 1:
            break
    if K%tmp == 0:
        print(Po)
    else:
        print(Im)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a):
  print("IMPOSSIBLE")
  exit()
import fractions
from functools import reduce

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
i = gcd_list(a)
if k%i == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Accepted

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

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

if len(L) == 1 :
    if L[0] == K :
        ans = "POSSIBLE"
    else :
        ans = "IMPOSSIBLE"

else :
    for i in range(N-1) :
        q = gcd(L[i],L[i+1])
        if i == 0 :
            p = gcd(L[i],L[i+1])
        if q < p :
            p = q

    if (K % p ==  0) and (K <= max(L)) :
        ans = "POSSIBLE"
    else :
        ans = "IMPOSSIBLE"
print(ans)

Submission status: Accepted

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

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a%b
    return b

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if K > a[-1]:
    print('IMPOSSIBLE')
    exit()

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

gc = a[0]
for x in a:
    gc = gcd(gc, x)
if K % gc == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

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

Submission status: Accepted

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

a = sorted(list(set(a)))

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

n = len(a)

if n > 1:
    m = 10**9
    for i in range(n-1):
        if a[i] != a[i+1]:
            m = min(m, abs(a[i+1]-a[i]))
    for i in range(n):
        if abs(a[i]-k) % m == 0:
            print("POSSIBLE")
            exit()
else:
    if a[0] == k:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Accepted

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

a_list.sort()
max_num = a_list[-1]

if max_num < K:
    print("IMPOSSIBLE")
    exit()

exist = a_list.count(K)
if exist >= 1:
    print("POSSIBLE")
    exit()

from fractions import gcd
gcd_num = gcd(a_list[-1], a_list[-2])

for a in a_list:
    gcd_num= gcd(gcd_num, a)
if K%gcd_num == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n>=2:
  g=gcd(a[0],a[1])
  for j in range(1,n):
    g=gcd(g,a[j])
  m=max(a)
  if k<=m and k%g==0:print('POSSIBLE')
  else:print('IMPOSSIBLE')
else:
  if a[0]==k:print('POSSIBLE')
  else:print('IMPOSSIBLE')

Submission status: Accepted

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

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

if max(As) < K:
    print('IMPOSSIBLE')
else:
    gcdA = As[0]
    for A in As[1:]:
        gcdA = gcd(gcdA, A)

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

Submission status: Accepted

Solution code:
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 x in a:
    g = gcd(g, x)
print(("IMPOSSIBLE", "POSSIBLE")[k <= max(a) and k % g == 0])

Submission status: Accepted

Solution code:
n, k=map(int, raw_input().split())
a=map(int, raw_input().split())
def gcd(a, b):
	return gcd(b, a%b) if b else a
g=0
for i in range(n):
	g=gcd(g, a[i])
print "IMPOSSIBLE" if k%g!=0 or k>max(a) else "POSSIBLE"

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

Submission status: Accepted

Solution code:
from functools import reduce
N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))

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

v = reduce(lambda a,b:gcd(a,b) , A)
if K % v == 0 and max(A) >= K :
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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

n,k = map(int, input().split())
list_a = list(map(int, input().split()))
g = list_a[0]
for i in range(1,n):
    g = gcd(g,list_a[i])
if k > max(list_a):
    print("IMPOSSIBLE")
else:
    if k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

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

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

G = A[0]
for i in range(1,N):
  G = GCD(G,A[i])
  #print(i,G,A[i])
  
if K % G == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions
n,m = map(int,input().split())
lis = list(map(int,input().split()))
num = lis[0]
for i in range(1,n):
  num = fractions.gcd(num,lis[i])
if m <= max(lis) and m % num == 0:
  print("POSSIBLE")
else:print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
import copy
Z = copy.deepcopy(A)
#for i in range(1, N):
 #   Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0

while True:
    if i >= len(Z):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    elif i > 0 and Z[i] == Z[i - 1]:
        del Z[i]
        i -= 1
    i += 1

ans = -1

import fractions
gcd = Z[0]
for i in range(1, len(Z)):
    gcd = fractions.gcd(gcd, Z[i])

if K % gcd == 0:
    ans = 1
    
if K > max(A):
    ans = -1
       
for i in A:
    if K == i:
        ans = 1
        break

if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Accepted

Solution code:
from functools import reduce

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

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

if K % reduce(gcd, A) or K > max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Accepted

Solution code:
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)
if k<=max(a) and k%G==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
f = lambda: map(int,input().split())


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


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

Submission status: Accepted

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

def gcd(a, b):
    #aとbの最大公約数を求める
    #math.gcdもしくはnp.gcdを使えばいいのだが、AtCoder上のpythonでは使えない
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        c = a % b
        return gcd(b, c)
def gcd_list(l):
    #リストlに対して、lの要素の最大公約数を返す
    d = l[0]
    for i in range(len(l) - 1):
        d = gcd(d, l[i + 1])
    return d

d = gcd_list(ball)
if K <= max(ball) and K % d == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

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


yes, no = "POSSIBLE", "IMPOSSIBLE"
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
if N == 1:
    print(yes if A[0] == K else no)
elif K > max(A):
    print(no)
else:
    GCD = gcd(A[0], A[1])
    for i in range(2, N):
        GCD = gcd(GCD, A[i])
    print(yes if K % GCD == 0 else no)

Submission status: Accepted

Solution code:
def gcd(t, u):
    if t < u:#t > uにする
        t, u = u, t
    while u > 0:
##        print(t, u)
        t, u = u, t % u
    return t

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

n, k = nl()
a = nl()

g = a[0]
for x in a:
##    print(g)
    g = gcd(x, g)

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