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

Submission status: Accepted

Solution code:
from math import gcd
N,K = map(int,input().split())
A = list(map(int,input().split()))
val = A[0]
for i in range(1,N):
    val = gcd(val,A[i])
if K % val == 0 and K <= max(A):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


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

g = A[0]

for x in A:
	g = gcd(g, x)


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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

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

G = A[0]

for i in range(1, N+1):
	G = gcd(G, A[i-1])
	if G == 1:
		break

if K%G == 0 and K <= max(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)

def main():
    N, K = map(int, input().split())
    A = tuple(map(int, input().split()))
    MAX_VAL = max(A)

    A_GCD = A[0]

    for a in A:
        A_GCD = gcd(A_GCD, a)
    
    if K <= MAX_VAL and K % A_GCD == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

def mgcd(l):
  return reduce(gcd,l)
if k in a:
  print("POSSIBLE")
  exit()
if a[-1]<k:
  print("IMPOSSIBLE")
  exit()
s = mgcd(a)
if s==1:
  print('POSSIBLE')
else:
  if k%s==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()
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: Accepted

Solution code:
from math import gcd

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

gcd_num = a[0]
for ai in a[1:]:
    gcd_num = gcd(gcd_num,ai)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
def hcf(l):
    return reduce(math.gcd, l)
gcd = hcf(A)
m = max(A)
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

n,k = map(int, readline().split())

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

import math
from functools import reduce
g = reduce(math.gcd, 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())) 
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: Accepted

Solution code:
def main():
    import math
    from functools import reduce
    def gcd_list(l):
        return reduce(math.gcd, l)
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    g = gcd_list(A)
    m = max(A)
    if k % g == 0 and k <= m:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import gcd
n,k=map(int,input().split())
*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 k%tmp!=0 or max(a)<k:
  print("IMPOSSIBLE")
else: print("POSSIBLE")

Submission status: Accepted

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

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

if K > max(A):
    print("IMPOSSIBLE")
else:
    now = A[0]
    for i in range(1,N):
        now = euclid(now,A[i])

    if now == 1:
        print("POSSIBLE")
    elif K % now == 0:
        print("POSSIBLE")
    elif K in A:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

I="IMPOSSIBLE"
P="POSSIBLE"

if max(a)<k:
    print(I)
    quit()

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

if k%gcd==0:
    print(P)
else:
    print(I)

Submission status: Accepted

Solution code:
from math import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

    if B == 1:
        print('POSSIBLE')
        exit()
    
    if K % B == 0:
        print('POSSIBLE')
        exit()

    print('IMPOSSIBLE')

    



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(read().split(), np.int32)

g = np.gcd.reduce(A)
cond = (K % g == 0) and (K <= A.max())
print('POSSIBLE' if cond else 'IMPOSSIBLE')

Submission status: Accepted

Solution code:
from math import gcd
N,K=map(int,input().split())
A=list(map(int,input().split()))
g=A[0]
if max(A)<K:
    print('IMPOSSIBLE')
    exit()
for i in range(1,N):
    g=gcd(g,A[i])

for i in range(N):
    if (A[i]-K)%g==0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Submission status: Accepted

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

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

m = max(A)
if m < K:
    print('IMPOSSIBLE')
else:
    if l == 1:
        print('POSSIBLE')
    else:
        for i in range(N):
            if abs(A[i]-K)%l == 0:
                print('POSSIBLE')
                break
        else:
            print('IMPOSSIBLE')

Submission status: Accepted

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

from fractions import gcd   #for python3.4
from math import gcd        #for python3.8

def Gcd(lt):
    l = len(lt)
    ret = [1]*l
    ret[0] = lt[0]
    for i in range(1,l):
        ret[i] = gcd(ret[i-1], lt[i])
    return ret

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    g = Gcd(A)[-1]
    if K<=max(A) and K%g==0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n,k = lr()
a = lr()
tmp = max(a)
if tmp < k:
    print('IMPOSSIBLE')
    sys.exit()
import fractions
from functools import reduce

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

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

g = gcd_list(a)
if k%g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
from fractions import gcd

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

if K in As:
  print('POSSIBLE')
  exit()
if K > max(As):
  print('IMPOSSIBLE')
  exit()
  
r = As[0]

for i in range(1,N):
  r = gcd(As[i],r)
  
if K%r != 0:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE')

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce


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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce


N, K = map(int, input().split())
A = list(map(int, input().split()))
g = reduce(gcd, A)
if K <= max(A) and (g == 1 or K % g == 0):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from fractions 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: Accepted

Solution code:
import sys
input = sys.stdin.readline
from fractions import gcd
from functools import reduce


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    a = reduce(gcd, A)
    if max(A) < K:
        return "IMPOSSIBLE"
    if a > 1 and K % a != 0:
        return "IMPOSSIBLE"
    return "POSSIBLE"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

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

import fractions
from functools import reduce
def calc_gcd(A):
    return reduce(fractions.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: Accepted

Solution code:
from functools import reduce
_, k, *lst = map(int, open(0).read().split())
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a
a = reduce(gcd, lst)
print('IMPOSSIBLE' if k > max(lst) or k % a else 'POSSIBLE')

Submission status: Accepted

Solution code:
from fractions 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: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,K = IL()
A = IL()
GCD = A[0]
for a in A[1:]:
  GCD = gcd(GCD,a)
MAX = max(A)
if K<=MAX and (MAX-K)%GCD==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    gcd_n = reduce(gcd, A)
    max_a = max(A)
    
    if K % gcd_n == 0 and K <= max_a:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import fractions

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=fractions.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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import fractions
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
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])
#print(x)
if k % x == 0 and k <= max(dat):
    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 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)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
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()))


# ===CODE===


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

Submission status: Accepted

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

Submission status: Accepted

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