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:
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

aN.sort()
base = aN[0]
has_odd = False
is_diverse = False
for i in range(N):
    # 奇数が入っているか
    if aN[i] % 2 == 1:
        has_odd = True
    # 倍数以外のものが入っているか
    if aN[i] % base != 0:
        is_diverse = True
# 奇数もあって倍数以外もあれば何でもできる
if has_odd and is_diverse:
    print('POSSIBLE')
# 倍数以外があっても奇数がなかったら行けるのは偶数だけ
elif not has_odd and is_diverse:
    if K % 2 == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    # 全部baseの倍数だったら、baseの倍数にしか動けない
    if K % base == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Submission status: Wrong Answer

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

mA=max(A)

search=[K]
searched=[]
while True:
	if len(search)==0:
		print('IMPOSSIBLE')
		exit(0)
	for i in range(N):
		tmp=[A[i]-search[0],A[i]+search[0]]
		if tmp[0] in A or tmp[1] in A:
			print("POSSIBLE")
			exit(0)
		if tmp[0]>0 and tmp[0] not in searched and tmp[0] not in search:
			search.append(tmp[0])
		if tmp[1]<mA and tmp[1] not in searched and tmp[1] not in search:
			search.append(tmp[1])
	if search[0] not in searched:
		searched.append(search[0])
	search.pop(0)

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)

def gojoho(l, s):
    return s if l % s == 0 else gojoho(s, l % s)

koubaisu = gojoho(a[1], a[0])
for i in a:
    koubaisu = gojoho(a[1], koubaisu)

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

Submission status: Wrong Answer

Solution code:
a,b=map(int, input().split())
x = list(map(int, input().split()))
x.sort()
p=0
q=0
y=0
for i in x:
    if p == 1 and q == 1:break
    if i == b:
        y=1
    if i%2==0:
        p=1
    else:
        q=1
if b<=x[-1]:
    if((b%2==0 and(p*q ==0))or(p==1 and q==1)):
        m="POSSIBLE"
if y==1:m="POSSIBLE"
else:m="IMPOSSIBLE" 
print(m)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
  return reduce(gcd, numbers)
n,k = map(int, input().split())
a = list(map(int, input().split()))
if k % gcd_list(a) == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
  return reduce(gcd, numbers)
n,k = map(int, input().split())
a = list(map(int, input().split()))
if n % gcd_list(a) == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

A.sort()

if A[-1]<K:
	print 'IMPOSSIBLE'
elif K in A:
	print 'POSSIBLE'
else:
	if len(A)==1:
		print 'IMPOSSIBLE'
	else:
		for i,x in enumerate(A):
			if i==0:
				v=x
			else:
				if x%v!=0:
					print 'POSSIBLE'
					quit()
		else:
			if K%v==0:
				print 'POSSIBLE'
			else:
				print 'IMPOSSIBLE'

Submission status: Wrong Answer

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

A.sort()

if A[-1]<K:
	print 'IMPOSSIBLE'
elif A[-1]==K:
	print 'POSSIBLE'
else:
	if len(A)==1:
		print 'IMPOSSIBLE'
	else:
		for i,x in enumerate(A):
			if i==0:
				v=x
			else:
				if x%v!=0:
					print 'POSSIBLE'
					quit()
		else:
			if K%v==0:
				print 'POSSIBLE'
			else:
				print 'IMPOSSIBLE'

Submission status: Wrong Answer

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

A.sort()

if A[-1]<K:
	print 'IMPOSSIBLE'
elif A[-1]==K:
	print 'POSSIBLE'
else:
	if len(A)==1:
		print 'IMPOSSIBLE'
	else:
		for i,x in enumerate(A):
			if i==0:
				v=x
			else:
				if x%v!=0:
					print 'POSSIBLE'
					quit()
		else:
			print 'IMPOSSIBLE'

Submission status: Wrong Answer

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

A.sort()

if A[-1]<K:
	print 'IMPOSSIBLE'
elif A[-1]==K:
	print 'POSSIBLE'
else:
	if len(A)==1:
		print 'IMPOSSIBLE'
	else:
		for i,x in enumerate(A):
			if i==0:
				v=x
			else:
				if v%x!=0:
					print 'POSSIBLE'
					quit()
		else:
			print 'IMPOSSIBLE'

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = ["POSSIBLE","IMPOSSIBLE"]
if max(A) < K:
    print(ans[1])
    exit()
A_mod = [e % K for e in A]
for i in range(N):
    if A_mod[i] == 0:
        print(ans[0])
        exit()
    if A_mod[i] == 1:
        continue
    for j in range(i+1,N):
        if A_mod[j] % A_mod[i] == 0:
            print(ans[0])
            exit()
print(ans[1])

Submission status: Wrong Answer

Solution code:
import math

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

S_possible = "POSSIBLE"
S_impossible = "IMPOSSIBLE"

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

Submission status: Wrong Answer

Solution code:
# import math
import fractions
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)

if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
div = a[0]
for i in range(1, n):
    div = fractions.gcd(div, a[i])

if k % div == 0 and k <= a[-1]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""
b = []
for i in range(len(a)):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    elif a[i] > k:
      b.append(a[i] - k)
      del(a[i])
print(a)
print(b)
"""

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

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

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

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

y=0
for i in range(n):
  if a[i]==k:
    y=1
if max(a)<k:
  print('IMPOSSIBLE')
else:
  if (k%x==0):
    print('POSSIBLE')
  elif y==1:
    print('POSSIBLE')
  else:
    print('IMPOSIBLE')

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L,reverse=False)

ans = "IMPOSSIBLE"
if L[-1] < K :
    ans = "IMPOSSIBLE"
elif (K in L) or (1 in L) : 
    ans = "POSSIBLE"
else :
    flag = 0
    for i in range(1,N) :
        if L[i] % L[0] != 0 :
            ans = "POSSIBLE"
            flag = 1
            break
    
    if flag == 0 :
        for i in range(N) :
            if (K + L[i]) in L :
                ans = "POSSIBLE"

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L,reverse=False)

ans = "IMPOSSIBLE"
if L[-1] < K :
    ans = "IMPOSSIBLE"
elif (K in L) or (1 in L) : 
    ans = "POSSIBLE"
else :
    for i in range(1,N) :
        if L[i] % L[0] != 0 :
            ans = "POSSIBLE"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
flag = 0
if A[-1] < K :
    flag = 0
else :
    if (1 in A) or (K in A) :
        flag = 1
    else :
        for i in range(N) :
            for j in range(i,N) :
                if A[j] % A[i] != 0 :
                    flag = 1
if flag == 1 :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
flag = 0
if A[-1] < K :
    flag = 0
else :
    if (1 in A) or (K in A) :
        flag = 1
    else :
        for i in range(N) :
            if K % A[i] == 0 :
                flag = 1
            elif A[i] % A[0] != 0 :
                flag = 1
if flag == 1 :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
flag = 0
if A[-1] < K :
    flag = 0
elif K in A :
    flag = 1
elif 1 in A :
    flag = 1
else :
    if K % A[0] == 0 :
        flag = 1
    else :
        for i in range(N) :
            if A[i] % A[0] != 0 :
                flag = 1
                break

if flag == 1 :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A)
flag = 0
if A[-1] < K :
    flag = 0
elif K in A :
    flag = 1
elif 1 in A :
    flag = 1
else :
    for i in range(N) :
        if A[i] % A[0] != 0 :
            flag = 1
            break

if flag == 1 :
    print("POSSIBLE")
else :
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = set(map(int,input().split()))
ans = 0
num = 0
if k in a:
    ans += 1
for i in a:
    if i-k > 0:
        if i-k in a:
            ans += 1
            break        
    if k+1 in a:
        ans += 1
        break
if ans >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = set(map(int,input().split()))
ans = 0
num = 0
if k in a:
    ans += 1
for i in a:
    if i-k < 0:
        num = k-i
    else:
        num = i-k
    if num in a:
        ans += 1
        break
if ans >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = set(map(int,input().split()))
ans = 0
num = 0
for i in a:
    if i-k < 0:
        num = k-i
    else:
        num = i-k
    if num in a:
        ans += 1
        break
if ans >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = set(map(int,input().split()))
ans = 0
for i in a:
    if i-n < 0:
        num = n-i
    else:
        num = i-n
    if num in a:
        ans += 1
        break
if ans >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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

if listA[len(listA)-1] < k:
    print("IMPOSSIBLE")
else:
    index=0
    waruru = listA[0]
    while index < len(listA):
        if listA[index]%waruru!=0:
            print("POSSIBLE")
            break
        if listA[index] == k:
            print("POSSIBLE")
        else:
            index+=1
    if index == len(listA):
        print("IMPOSSIBLE")

Submission status: Wrong Answer

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

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

ans = -1

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

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

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

Submission status: Wrong Answer

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

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

ans = -1
for i in range(1, len(Z)):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
if K > max(A):
    ans = -1
    
for i in A:
    if K == i:
        ans = 1
        break
import fractions
for i in range(1, len(Z)):
    if fractions.gcd(Z[i - 1], Z[i]) == fractions.gcd(fractions.gcd(Z[i - 1], Z[i]), K):
        ans = 1
    
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

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

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

ans = -1
for i in range(1, len(Z)):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
if K > max(A):
    ans = -1
    
for i in A:
    if K == i:
        ans = 1
        break
import fractions
for i in range(1, len(Z)):
    if fractions.gcd(Z[i - 1], Z[i]) == fractions.gcd(fractions.gcd(Z[i - 1], Z[i]), K):
        ans = 1
    
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i >= len(Z):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1

ans = -1
for i in range(1, len(Z)):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
    
for i in A:
    if K == i:
        ans = 1
        
if K > max(A):
    ans = -1
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i >= len(Z):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1

ans = -1
for i in range(1, len(Z)):
    if Z[i - 1] % Z[i] != 0:
        ans = 1
        break
    
for i in A:
    if K == i:
        ans = 1
        
if K >= max(A):
    ans = -1
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
Z = []
for i in range(1, N):
    Z.append(abs(A[i] - A[i - 1]))
Z.sort()
i = 0
while True:
    if i >= len(Z):
        break
    if Z[i] == 0:
        del Z[i]
        i -= 1
    i += 1

    
for i in range(1, len(Z)):
    ans = -1
    if Z[i - 1] % Z[i] != 0:
        ans = 1
    
for i in A:
    if K == i:
        ans = 1
        
if K >= max(A):
    ans = -1
    
if ans == -1:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

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

makable = False
if max(A) < K:
    makable = False
elif K in A:
    makable = True

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
new_A = set([A[i]-A[i-1] for i in range(len(A)-1, 0, -1)])
max_a = A[-1]
set_A = set(A)
if k in A:
    print("POSSIBLE")
elif max_a >= k:
    if new_A - set_A == set():
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")
elif max_a < k:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

flg = 1
inpointer = 0

def calc():
    global flg
    global inpointer
    #print(inpointer)
    flg = 0
    lo = len(a)
    for i in range(len(a)):
        for j in range(inpointer,len(a)):
            #print(a[i],a[j])

            if i == j:
                continue
            else:
                if (abs(a[i] - a[j]) not in a):
                    a.append(abs(a[i]-a[j]))
                    flg = 1
    else:
        inpointer = lo
        #print(a)
while(flg == 1):
    #print("com")
    calc()

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

Submission status: Wrong Answer

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

flg = 1
inpointer = 0

def calc():
    global flg
    global inpointer
    flg = 0
    for i in range(len(a)):
        for j in range(inpointer,len(a)):
            inpointer = len(a)
            if i == j:
                continue
            else:
                if (abs(a[i] - a[j]) not in a):
                    a.append(abs(a[i]-a[j]))
                    flg = 1
    #else:
        #print(a)
while(flg == 1):
    calc()

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

if n == 1:
	if n == k:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")
else:
	if k in a:
		print("POSSIBLE")
	elif k > max(a):
		print("IMPOSSIBLE")
	else:
		g = gcd(a[0], a[1])
		for i in range(2, n):
			g = gcd(g, a[i])

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

if n == 1:
	if n == k:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")
else:
	if k > max(a):
		print("IMPOSSIBLE")
	else:
		g = gcd(a[0], a[1])
		for i in range(2, n):
			g = gcd(g, a[i])

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
t=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
ans=t[0]
for i in range(n):
    ans=gcd(ans,t[i])
if k%ans==0:
    if k<max(t):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
t=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
ans=t[0]
for i in range(n):
    ans=gcd(ans,t[i])
if k%ans==0 and k<max(t):
    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!=0:
        a,b=b,a%b
    return a
ans=a[0]
for i in range(1,n):
    ans=gcd(ans,a[i])
if ans%k==0:
    if k<max(a):
        print("POSSIBLE")
        exit()
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!=0:
        a,b=b,a%b
    return a
ans=a[0]
for i in range(1,n):
    ans=gcd(ans,a[i])
if k%ans==0:
    if k<max(a):
        print("POSSIBLE")
        exit()
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!=0:
        a,b=b,a%b
    return a
ans=a[0]
for i in range(n):
    ans=gcd(ans,a[i])
if k%ans==0:
    if k<max(a):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import functools
import math

n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
a1=max(a)
s=a1
for a0 in a:
  s = min(s,abs(a0-a1))
  a1=a0
  
ma=max(a)
if c in a:
  print('POSSIBLE')
elif s==0:
  print('IMPOSSIBLE')
elif all([i % s==0 for i in a])==False:
  print('POSSIBLE')
else:
  while c<=ma:
    ma-=s
    if c==ma:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
a1=max(a)
s=a1
for a0 in a:
  s = min(s,abs(a0-a1))
  a1=a0
  
ma=max(a)
if s==0:
  print('IMPOSSIBLE')
elif all([i % s==0 for i in a])==False:
  print('POSSIBLE')
else:
  while c<=ma:
    ma-=s
    if c==ma:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print("IMPOSSIBLE")
    exit()
elif K in A:
    print("POSSIBLE")


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


while len(A) > 1:
    A.append(gcd(A.pop(), A.pop()))

if A[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()))
mA = min(A)
if max(A) < K:
    print("IMPOSSIBLE")
    exit()
elif any(map(lambda x: x%mA != 0, A)) or K in A:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

if max(A) < K:
    print("IMPOSSIBLE")
    exit()
elif any(map(lambda x: x%min(A) != 0, A)):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
loop=True
if k > max(a):
    loop=False
    flag=False
    result="IMPOSSIBLE"
if k % 2 == 1:
    loop=False
    flag=False
    result="IMPOSSIBLE"
    for i in range(len(a)):
        if a[i]%2==1:
            loop=False
            flag=True
            result="POSSIBLE"
            break

print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
loop=True
if k > max(a):
    loop=False
    flag=False
    result="IMPOSSIBLE"
if k % 2 == 1:
    loop=False
    flag=False
    result="IMPOSSIBLE"
    for i in range(len(a)):
        if a[i]%2==1:
            loop=False
            flag=True
            result="POSSIBLE"
            break

if not k in a:
    b=[]
    a.sort()
    for i in range(1,len(a)):
        if a[i]%a[0] !=0:
            b.append(a[i])
            break
    if len(b)==0:
        loop=False
        flag=False
        result="IMPOSSIBLE"


            


while flag and loop:
    if k in a:
        break
    a.sort()
    b=[]
    i=0
    while i < len(a):
        b.append(a[i])
        j = i+1
        while j < len(a):
            num = a[j]%a[i]
            if num == 0:
                a.pop(j)
            else:
                if not num in b:
                    b.append(num)
                j = j + 1
        i=i+1
    if len(a) == len(b):
        result="IMPOSSIBLE"
        break
    a=b
    a.sort()
    if k in a:
        break
    if 1 in a:
        break
    if len(a) == 0:
        result="IMPOSSIBLE"
        break
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
if k > max(a):
    flag=False
    result="IMPOSSIBLE"
if k % 2 == 1:
    flag=False
    result="IMPOSSIBLE"
    for i in range(len(a)):
        if a[i]%2==1:
            flag=True
            result="POSSIBLE"
            break

if not k in a:
    b=[]
    a.sort()
    for i in range(1,len(a)):
        if a[i]%a[0] !=0:
            b.append(a[i])
            break
    if len(b)==0:
        flag=False
        result="IMPOSSIBLE"


            


# while flag:
#     if k in a:
#         break
#     a.sort()
#     b=[]
#     i=0
#     while i < len(a):
#         b.append(a[i])
#         j = i+1
#         while j < len(a):
#             num = a[j]%a[i]
#             if num == 0:
#                 a.pop(j)
#             else:
#                 if not num in b:
#                     b.append(num)
#                 j = j + 1
#         i=i+1
#     if len(a) == len(b):
#         result="IMPOSSIBLE"
#         break
#     print(a)
#     print(b)
#     sys.exit()
#     a=b
#     a.sort()
#     if k in a:
#         break
#     if 1 in a:
#         break
#     if len(a) == 0:
#         result="IMPOSSIBLE"
#         break
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"
flag=True
if k > max(a):
    flag=False
    result="IMPOSSIBLE"
if k % 2 == 1:
    for i in range(len(a)):
        if a[i]%2==1:
            break
    flag=False
    result="IMPOSSIBLE"


while flag:
    if k in a:
        break
    a.sort()
    b=[]
    i=0
    while i < len(a):
        b.append(a[i])
        j = i+1
        while j < len(a):
            num = a[j]%a[i]
            if num == 0:
                a.pop(j)
            else:
                if not num in b:
                    b.append(num)
                j = j + 1
        i=i+1
    if len(a) == len(b):
        result="IMPOSSIBLE"
        break
    a=b
    a.sort()
    if k in a:
        break
    if 1 in a:
        break
    if len(a) == 0:
        result="IMPOSSIBLE"
        break
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"


while True:
    if k in a:
        break
    a.sort()
    b=[]
    i=0
    while i < len(a):
        b.append(a[i])
        j = i+1
        while j < len(a):
            num = a[j]%a[i]
            if num == 0 or num in b:
                a.pop(j)
            else:
                b.append(num)
                j = j + 1
        i=i+1
    if len(a) == len(b):
        result="IMPOSSIBLE"
        break
    a=b
    a.sort()
    if k in a:
        break
    if 1 in a:
        break
    if len(a) == 0:
        result="IMPOSSIBLE"
        break
    # a.sort()
    # b=[]    
    # for i in range(len(a)-1):
    #     b.append(a[i])
    #     for j in range(i+1,len(a)):
    #         num = a[j]%a[i]
    #         if not num in b:
    #             if num != 0:
    #                 b.append(num)
    # a=b
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

result="POSSIBLE"


while True:
    a.sort()
    b=[]
    i=0
    while i < len(a):
        b.append(a[i])
        j = i+1
        while j < len(a):
            num = a[j]%a[i]
            if num == 0 or num in b:
                a.pop(j)
            else:
                b.append(num)
                j = j + 1
        i=i+1
    a=b
    if k in a:
        break
    if 1 in a:
        break
    if len(a) == 0:
        result="IMPOSSIBLE"
        break
    a.sort()
    b=[]    
    for i in range(len(a)-1):
        b.append(a[i])
        for j in range(i+1,len(a)):
            num = a[j]%a[i]
            if not num in b:
                if num != 0:
                    b.append(num)
    a=b
print(result)