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: Wrong Answer

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

if max(a) < k:
    print('IMPOSSIBLE')
else:
    mod_std = min(a)
    if all(a[i]%mod_std == 0 for i in range(n)):
        if max(a) == k:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')
    else:
        print('POSSIBLE')

Submission status: Wrong Answer

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

if max(a) < k:
    print('IMPOSSIBLE')
else:
    mod_std = min(a)
    if all(a[i]%mod_std == 0 for i in range(n)):
        print('IMPOSSIBLE')
    else:
        print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
yes="POSSIBLE" ; no="IMPOSSIBLE"
import numpy as np
q= np.gcd.reduce(A)
if k%q==0 and max(A)-min(A)>=k:
    print(yes)
else:
    print(no)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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=0
max_a=0
for a in A:
	g=gcd(g, a)
	max_a=max(max_a, a)

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n = int(input())
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    g = reduce(gcd, a)
    print(g)
    m = max(a)
    if k <= m and k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
1
4
-1 1 1 -1

"""

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
n = len(a)
a1 = []

if max(a) < k:
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    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: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a1 = []
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
if k in a:
    print("POSSIBLE")
    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: Wrong Answer

Solution code:
from math import gcd
n,k = map(int,input().split())
A = list(map(int,input().split()))
g = A[0]
for x in A:
    g = gcd(g,x)
print("POSSIBLE" if k%g == 0 else "IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce
n,k=map(int,input().split())
a=list((map(int,input().split())))
print(['POSSIBLE','IMPOSSIBLE'][k%reduce(gcd,a) and k>max(a)])

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
ls = list(map(int, input().split()))
ls.sort()
is_NG = True
for i in range(1,n):
    if ls[i] % ls[0] != 0:
        is_NG = False
res = False
if is_NG:
    if k % ls[0] == 0 and k <= ls[-1]:
        res = True
else:
    if k <= ls[-1]:
        res = True
if res:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    if max(A)<K:
        ans = 'IMPOSSIBLE'
    else:
        minA = min(A)
        for a in A:
            if a%minA==0:
                continue
            else:
                ans = 'POSSIBLE'
                break
        else:
            ans = 'IMPOSSIBLE'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
l = sorted(list(map(int,input().split())))
if l[-1] < k:
    print("IMPOSSIBLE")
    exit()
x = l[0]
for i in range(1,n):
    if l[i]%x:
        print("POSSIBLE")
        exit()

if k in l:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
l = sorted(list(map(int,input().split())))
if l[-1] > k:
    print("IMPOSSIBLE")
    exit()
x = l[0]
for i in range(1,n):
    if l[i]%x:
        print("POSSIBLE")
        exit()

if k in l:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

x = l[0]
for i in range(1,n):
    if l[i]%x:
        print("POSSIBLE")
        exit()

if k in l:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from math import gcd

n,k = map(int, input().split())
al = list(map(int, input().split()))
a_gcd = al[0]
for a in al[1:]:
    a_gcd = gcd(a_gcd,a)

if k%a_gcd == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy

def solve():
    n, k = getList()
    nums = getList()
    nums.sort(reverse=True)
    c = nums[0]
    if c < k:
        print("IMPOSSIBLE")
        return
    for num in nums[1:]:
        c = math.gcd(c, num)
    print(c)
    if k % c == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")



def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()

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

    A.sort()

    if K in A:
        print('POSSIBLE');exit()
    if max(A)<K:
        print('IMPOSSIBLE');exit()
        
    import heapq

    heapq.heapify(A)
    while A[1]-A[0]<A[0]:
        heapq.heappush(A,A[1]-A[0])
    
    if (max(A)-K)%A[0]==0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
n,k = map(int,input().split())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
if k%ans == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())))
lA = A[0]
b = []
c= []
for i in range(len(A)):
    if i !=0:
        b.append(A[i]%lA)
        if A[i]%lA!=0:
            b.append(lA-(A[i]%lA))
    c.append(A[i]%K)

b=set(b)
if (1 in b) and K <= max(A):
    print('POSSIBLE')
    exit()
c=set(c)
d = b&c
if len(d) ==0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())))
lA = A[0]
b = []
c= []
for i in range(len(A)):
    if i !=0:
        b.append(A[i]%lA)
        if A[i]%lA!=0:
            b.append(lA-(A[i]%lA))
    c.append(A[i]%K)

b=set(b)
c=set(c)
d = b&c
if len(d) ==0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

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:
    if len(lis)>1:
        lis.append(lis[-2]%lis[-1])
        n+=1
    else:
        break
#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: Wrong Answer

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)
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: Wrong Answer

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(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

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

def solve():   
    if N == 1:  return A == K    
    g = gcd(A)
    m = max(A)
    return K < m and K % g == 0

N, K = cin()
A = cin()
ret = solve()
if ret:  print("POSSIBLE")
else:  print("IMPOSSIBLE")

Submission status: Wrong Answer

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():   
    if N == 1:  return A == K    
    g = gcd_bl(A)
    for i in range(N):
        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: Wrong Answer

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: Wrong Answer

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

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

flag = False
for i in arr:
  if i > k:
    if 1 in arr:
      print("POSSIBLE")
      exit()
    flag = True
    break
if flag:
  print("IMPOSSIBLE")
  exit()

while True:
  tmp = []
  for i in range(len(arr)-1):
    for k in range(i, len(arr)-1):
    	tmp.append(abs(arr[i]-arr[k+1]))
  tmp = list(set(tmp))
  
  if k in tmp:
    print("POSSIBLE")
    exit()

  if len(set(arr+tmp)) == len(arr) or len(set(arr+tmp)) == len(tmp):
    print("IMPOSSIBLE")
    exit()
    
  arr = list(set(arr+tmp))

Submission status: Wrong Answer

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

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

tmp = []
for i in range(len(arr)-1):
  tmp.append(abs(arr[i]-arr[i+1]))
tmp.append(abs(arr[0]-arr[-1]))           
s = list(set(tmp))

if len(set(arr+s)) == len(arr) or len(set(arr+s)) == len(s):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Submission status: Wrong Answer

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

if K in A:
    print("POSSIBLE")
elif (A.max() < K) | (A.min() == A.max()):
    print("IMPOSSIBLE")
else:
    for i in range(N):
        for j in range(i + 1, N):
            if abs(A[i] - A[j]) not in A:
                print("POSSIBLE")
                sys.exit()
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

if K in A:
    print("POSSIBLE")
elif A.max() < K:
    print("IMPOSSIBLE")
else:
    for i in range(N):
        for j in range(i + 1, N):
            if abs(A[i] - A[j]) not in A:
                print("POSSIBLE")
                sys.exit()
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,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 copy import deepcopy
from time import time
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()
b = set()
s = sum(a)

for x in a:
    b.add(abs(s-2*x))

for x in a:
    diff = x - k
    if diff == 0 or ( diff > 0 and diff in b ):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 作れない数字
# ・最大値より大きい数字
# ・GCDの倍数でない数字

if k > a[0]:
    print('IMPOSSIBLE')
    exit()

import math

gcd = a[0]
for i in a[1:]:
    gcd = math.gcd(gcd, i)
    if k%gcd == 0:
        print('POSSIBLE')
        exit()
    
print('IMPOSSIBLE')

Submission status: Wrong Answer

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

# 作れない数字
# ・最大値より大きい数字
# ・GCDの倍数でない数字

if k > a[0]:
    print('IMPOSSIBLE')
    exit()

import math

for i in zip(a,a[1:]):
    gcd = math.gcd(*i)
    if k%gcd == 0:
        print('POSSIBLE')
        exit()
    
print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())

if max(As)<K:
    print('IMPOSSIBLE')
else:
    m = min(As)
    for a in As:
        if not a%m==0:
            print('POSSIBLE')
            break
    else:
        if K%m==0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')

Submission status: Wrong Answer

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 g <= max(A):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Wrong Answer

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:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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:
  print("POSSIBLE")
else: print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import itertools
def main():
    n,k=map(int, input().split())
    A=[int(i) for i in input().split()]
    minf = min(A)
    maxf = max(A)
    moda = [int(i)%minf for i in A]
    if(sum(moda)>0 or (k in A) or (k%minf==0)):
        res="POSSIBLE"
    else:
        res = "IMPOSSIBLE"
    if(maxf<k):
        res = "IMPOSSIBLE"

    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
def main():
    n,k=map(int, input().split())
    A=[int(i) for i in input().split()]
    minf = min(A)
    maxf = max(A)
    moda = [int(i)%minf for i in A]
    if(sum(moda)>0 or k in A):
        res="POSSIBLE"
    else:
        res = "IMPOSSIBLE"
    if(maxf<k):
        res = "IMPOSSIBLE"

    print(res)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,K= map(int, input().split())
A = sorted(map(int,input().split()),reverse=True)
if A.count(K) >=1:
    print("POSSIBLE")
elif A.count(1) >=1:
    print("POSSIBLE")
elif A[0]<K:
    print("IMPOSSIBLE")
elif N ==2:
    if K % (A[0-A[1]])!=0:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
        
    
else:
    M =[]
    for i in range (len(A)-1):
        M.append(A[i]-A[i+1])
    m = list(set(M))
    if M.count(1) >=1:
        print("POSSIBLE")
    else:
        if len(m)!=1:
            print("POSSIBLE")
        else:
            if (A[-1] % m[0])== 0:
                if (K % m[0])!= 0:
                    print("IMPOSSIBLE")
                else:
                    print("POSSIBLE")
            elif (K - A[0] )== 1:
                print("IMPOSSIBLE")
            else:
                print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K= map(int, input().split())
A = sorted(map(int,input().split()),reverse=True)
if A.count(K) >=1:
    print("POSSIBLE")
elif A[0]<K:
    print("IMPOSSIBLE")
    
else:
    M =[]
    for i in range (len(A)-1):
        M.append(A[i]-A[i+1])
    m = list(set(M))
    if M.count(1) >=1:
        print("POSSIBLE")
    else:
        if len(m)!=1:
            print("POSSIBLE")
        else:
            if (A[-1] % m[0])== 0:
                if (K % m[0])!= 0:
                    print("IMPOSSIBLE")
                else:
                    print("POSSIBLE")
            elif (K - A[0] )== -1:
                print("IMPOSSIBLE")
            else:
                print("POSSIBLE")

Submission status: Wrong Answer

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 in A or (K <= max(A) and (g == 1 or K % g == 0)):
    print("POSSIBLE")
else:
    print("IMPOSSBILE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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

Submission status: Wrong Answer

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) if A[i]!= A[i-1]]
da.sort()

ma = []
if da: ma.append(min(da))
ma.append(min(A))

set1 = set()

for a in A:
    for i in ma:
        if i != 0:
            set1.add(a%i)

#print(A, da, ma)
#print(set1)
jdg = False
if K <= max(A):
    for i in set1: 
        if i != 0 and K%i == 0:jdg = True

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

Submission status: Wrong Answer

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) if A[i]!= A[i-1]]
da.sort()

ma = []
if da: ma.append(min(da))
ma.append(min(A))

set1 = set()

for a in A:
    for i in ma:
        if i != 0:
            set1.add(a%i)

print(A, da, ma)
print(set1)
jdg = False
if K <= max(A):
    for i in set1: 
        if i != 0 and K%i == 0:jdg = True

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

Submission status: Wrong Answer

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) if A[i]!= A[i-1]]
da.sort()

if da: mda = min(da)
else: mda = min(A)
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: Wrong Answer

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 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 % i == 0 and k <= max(i, b):
    print('POSSIBLE')
    exit()
else:
  print('IMPOSSIBLE')

Submission status: Wrong Answer

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 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:
  if k > i:
    print('IMPOSSIBLE')
    exit()
  g = fractions.gcd(i, b)
  if g == 1:
    print('POSSIBLE')
    exit()
  s.add(g)
for i in tuple(s):
  if k % i == 0:
    print('POSSIBLE')
    break
else:
  print('IMPOSSIBLE')

Submission status: Wrong Answer

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 = 1
if k in a:
  print('POSSIBLE')
if tuple(set(a))[0] == 1:
  if k <= n:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  exit()
for i in a:
  g = fractions.gcd(i, b)
  if g == 1:
    print('POSSIBLE')
    exit()
  s.add(g)
for i in tuple(s):
  if k % i == 0:
    print('POSSIBLE')
    break
else:
  print('IMPOSSIBLE')