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:
#! /usr/bin/env python3

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

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

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

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

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

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:

from fractions import gcd


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


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

Submission status: Accepted

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

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

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

j(N, K, a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, A = map(int, input().split())
tmp = input()
ary = [int(a) for a in tmp.split()]

maximum = max(ary)


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


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

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

Submission status: Accepted

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

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

ans = False

A = sorted(A)

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

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

    if key_flag == False:
        ans = True
#         print(1)
    elif K % key == 0:
        ans = True
#         print(2)
    else:
#         print(3)
        ans = False           
    
if ans == True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
# A(300)
N, K = map(int, input().split())
A_list = list(map(int, input().split()))


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

    return x

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3


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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# from math import gcd
from fractions import gcd


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


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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

max_a = aa[0]

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

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

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

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

Submission status: Accepted

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

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

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

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

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

    return 'IMPOSSIBLE'


print(main())

Submission status: Accepted

Solution code:
import fractions

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

ans = "IMPOSSIBLE"

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions

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

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

solve(N, K, As)

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('a1.in')


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


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


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


def read_str():
    return input()


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


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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd


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


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

Submission status: Accepted

Solution code:
from fractions import gcd

yes = "POSSIBLE"
no = "IMPOSSIBLE"

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

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

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

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

Submission status: Accepted

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

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

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

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

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

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
a = list(set(map(int, input().split())))
a.sort(); b = a[0]
for i in range(1, n): b = gcd(b, a[i])
if len(a) == 1:
    print("POSSIBLE") if k == a[0] else print("IMPOSSIBLE")
else:
    print("POSSIBLE") if k <= a[-1] and k%b == 0 else print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a1 = []
if max(a) < k:
    print("IMPOSSIBLE")
    exit()

for i in range(1, n):
    a1.append(abs(a[i-1]-a[i]))
a1 = sorted(a1)

for i in range(1, n-1):
    if a1[i] % a1[0] != 0:
        print("POSSIBLE")
        break
else:
    if k % a1[0] == 0 or a1[0] == 1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
N,K=list(map(int,input().split()))
l=list(map(int,input().split()))
import math
A=math.gcd(l[0],l[1])
if K<=max(l):
   for i in range(max(0,N-2)):
      A=math.gcd(A,l[i+2])
   if K%A==0:
      print("POSSIBLE")
   else:
      print("IMPOSSIBLE")
else:
   print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
a = LIST()
mygcd = gcd(a[0],a[1])

for x in a:
    mygcd = gcd(mygcd,x)
for x in a:
    if x - k == 0 or ( x - k > 0 and ( x - k ) % mygcd == 0 ):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
a = LIST()
mygcd = gcd(a[0],a[1])

for x in a:
    mygcd = gcd(mygcd,x)
for x in a:
    if x - k >= 0 and ( x - k ) % mygcd == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
lis.sort(reverse=True)
while lis[-1]>10**5:
    lis.append(lis[-2]%lis[-1])
    n+=1
#print(lis)
lis.sort()
ex=[0 for i in range(lis[-1])]
for i in range(1,n):
    if ex[lis[i]%lis[-1]]==0:
        ex[lis[i]%lis[-1]]+=1
    if ex[lis[-1]-lis[i]%lis[-1]-1]==0:
        ex[lis[-1]-lis[i]%lis[-1]-1]+=1
#print(ex)
for i in range(n):
    if lis[i]<k:
        break
    elif lis[i]==k:
        print("POSSIBLE")
        sys.exit()
    elif ex[(lis[i]-k)%lis[-1]]==1:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
lis.sort(reverse=True)
while lis[-1]>10**5:
    lis.append(lis[-2]%lis[-1])
    n+=1
#print(lis)
ex=[0 for i in range(lis[-1])]
for i in range(1,n):
    if ex[lis[i]%lis[-1]]==0:
        ex[lis[i]%lis[-1]]+=1
    if ex[lis[-1]-lis[i]%lis[-1]-1]==0:
        ex[lis[-1]-lis[i]%lis[-1]-1]+=1
#print(ex)
for i in range(n):
    if lis[i]<k:
        break
    elif lis[i]==k:
        print("POSSIBLE")
        sys.exit()
    elif ex[(lis[i]-k)%lis[-1]]==1:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
lis.sort(reverse=True)
while lis[-1]>10**5:
    lis.append(lis[-2]%lis[-1])
    n+=1
ex=[0 for i in range(lis[-1])]
for i in range(1,n):
    if ex[lis[i]%lis[-1]]==0:
        ex[lis[i]%lis[-1]]+=1
    if ex[lis[-1]-lis[i]%lis[-1]-1]==0:
        ex[lis[-1]-lis[i]%lis[-1]-1]+=1
#print(ex)
for i in range(n):
    if lis[i]<k:
        break
    elif lis[i]==k:
        print("POSSIBLE")
        sys.exit()
    elif ex[(lis[i]-k)%lis[-1]]==1:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd_bl(A):

    left = [0 for _ in range(N + 1)]
    right = [0 for _ in range(N + 1)]
    ans = [0 for _ in range(N)]

    left[1] = A[0]
    for i in range(1, N):
        left[i + 1] = gcd_(left[i], A[i])
    right[-1 - 1] = A[-1]
    for i in range(1, N):
        right[-1 - i - 1] = gcd_(right[-1 - i], A[-1 - i])
    for i in range(N):
        ans[i] = gcd_(left[i], right[i + 1])
        
    return ans

def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

def solve():
    
    g = gcd_bl(A)

    for i in range(N):
        if A[i] == K:  return 1
        elif A[i] > K:
            temp = (K - A[i]) / g[i]
            if temp == int(temp):
                return 1

    return 0

N, K = cin()
A = cin()

ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_
    
def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

def gcd_bl(A):

    left = [0 for _ in range(N + 1)]
    right = [0 for _ in range(N + 1)]
    ans = [0 for _ in range(N)]

    left[1] = A[0]
    for i in range(1, N):
        left[i + 1] = gcd_(left[i], A[i])
    right[-1 - 1] = A[-1]
    for i in range(1, N):
        right[-1 - i - 1] = gcd_(right[-1 - i], A[-1 - i])

    for i in range(N):
        ans[i] = gcd_(left[i], right[N - i - 2])
        
    return ans

def solve():
    
    g = gcd_bl(A)

    for i in range(N):
        if A[i] == K:  return 1
        elif A[i] > K:
            temp = (K - A[i]) / g[i]
            if temp == int(temp):
                return 1

    return 0

N, K = cin()
A = cin()

ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

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

    n, k =map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    c = a[0]
    for i in range(n):
        c = gcd(a[i], c)
    if k%c == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    

    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

P = "POSSIBLE"
IP = "IMPOSSIBLE"

M = max(A)

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

t = gcd(A[1], A[0])
if N >= 2:
    for a in A[2:]:
        t = gcd(t, a)

if K%t == 0 and K <= M:
    print(P)
else:
    print(IP)

Submission status: Runtime Error

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

P = "POSSIBLE"
IP = "IMPOSSIBLE"

A.sort()

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

t = gcd(A[1], A[0])
if N <= 2:
    for a in A[2:]:
        t = gcd(t, a)

if K%t == 0 and K <= M:
    print(P)
else:
    print(IP)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split())) 
a.sort()
a.reverse() 
x = a[0]   
for i in range (1, N):
  while a[i] != 0:
    x , a[i] = a[i] , x % a[i]
if K > a[0]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = list(map(float, input().split()))
m = max(l)
def hcf(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 
num1=l[0] 
num2=l[1] 
gcd=hcf(num1,num2) 
for i in range(2,len(l)): 
    gcd=hcf(gcd,l[i])
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
m = max(l)
def hcf(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 
num1=l[0] 
num2=l[1] 
gcd=hcf(num1,num2) 
for i in range(2,len(l)): 
    gcd=hcf(gcd,l[i])
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
m = max(a)
def hcf(x, y): 
    while(y): 
        x, y = y, x % y 
    return x 
num1=l[0] 
num2=l[1] 
gcd=hcf(num1,num2) 
for i in range(2,len(l)): 
    gcd=hcf(gcd,l[i])
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
*a, =map(int,input().split())
a=sorted(a)
for i in range(len(a)):
  if i==0: tmp=a[0]
  else:
    tmp=gcd(tmp,a[i])
if n%tmp==0:
  print("POSSIBLE")
else: print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from math import gcd

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    
    if K > A[N-1]:
        print('IMPOSSIBLE')
    else:
        ans = 0
        for i in range(N):
            ans = gcd(ans,A[i])
            if ans == 1:
                print('POSSIBLE')
                exit()
        if (A[N-1]-K)%ans == 0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from functools import reduce
def calc_gcd(A):
    return reduce(math.gcd, A)

N,K = LI()
A = LI()

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
da = [abs(A[i] - A[i-1]) for i in range(1, N)]
da.sort()

mda = min(da)
ma = min(A)

set1 = set()
set2 = set()

for a in A:
    if ma != 0:
        set1.add(a%ma)
    if mda != 0:
        set2.add(a%mda)
set3 = set1 | set2

jdg = False
if K <= max(A):
    for i in set3: 
        if i != 0 and K%i == 0:jdg = True

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
da = [abs(A[i] - A[i-1]) for i in range(1, N)]
da.sort()

mda = min(da)
ma = min(A)

set1 = set()
set2 = set()

for a in A:
    set1.add(a%ma)
    set2.add(a%mda)
set3 = set1 | set2

jdg = False
if K <= max(A):
    for i in set3: 
        if i != 0 and K%i == 0:jdg = True

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

Submission status: Runtime Error

Solution code:
import math

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

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=math.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math

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

M=A[0]
gcd=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    gcd=math.gcd(gcd,A[i+1])

if k<=M:
    if gcd==1:
        print("POSSIBLE")
    elif k%gcd==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

a.sort()
#9,4,3>7
#9-(9-4-3)


#9 ;6 3 >5
if k in a:
    print("POSSIBLE")
    exit()

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

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

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

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import sys
import math

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 = math.gcd(A[0], A[1])

    for a in A:
        g = math.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()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
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)

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

Submission status: Runtime Error

Solution code:
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
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)

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

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

Submission status: Runtime Error

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