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:
import fractions

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

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=set(map(int,input().split()))
NO='IMPOSSIBLE'
YES='POSSIBLE'

max_A=max(A)
if K>max_A:
    print(NO)
    exit()

if K in A:
    print(YES)
    exit()

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

GCD=0
for n in A:
    GCD=gcd(GCD,n)

if GCD==1:
    print(YES)
else:
    print(NO)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, K = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for i in range(N):
    g = gcd(a[i], g)
amax = max(a)
q, mod = divmod(K, g)

if mod != 0:
    print('IMPOSSIBLE')
else:
    if q <= amax:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Submission status: Wrong Answer

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

if a.count(K) != 0:
    print('POSSIBLE')
    exit()

d = defaultdict(int)
d[0] += 1
for i in a:
    d[i] += 1
before = len(d)
for i in range(1, N):
    d[abs(a[i] - a[i - 1])] += 1
after = len(d)

if before == after:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

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

if a.count(K) != 0:
    print('POSSIBLE')
    exit()

d = defaultdict(int)
for i in a:
    d[i] += 1
before = len(d)
for i in range(1, N):
    d[abs(a[i] - a[i - 1])] += 1
after = len(d)

if before == after:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = 10 ** 10
    for i in range(1,n):
        tmp_gcd = fractions.gcd(a[i-1],a[i])
        if tmp_gcd < gcd:
            gcd = tmp_gcd
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=float('inf')
if k>max(a):
  print('IMPOSSIBLE')
else:
  for i in range(n):
    b=min(gcd(a[0],a[i]),b)
  if k%b==0:
     print('POSSIBLE')
  else:
    print('IMROSSIBLE')

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

N,K = map(int,input().split())
print('POSSIBLE' if K%reduce(gcd,map(int,input().split())) ==0 else 'IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, K = MAP()
	A = MAP()

	# max(A) < K の場合は達成不可
	# 絶対値差の集合にA以外の数が存在しない場合は達成不可

	if A.count(K) > 0:
		print('POSSIBLE')
	elif max(A) < K:
		print('IMPOSSIBLE')
	else:
		B = []
		for i in range(N-1):
			B.append(abs(A[i]-A[i+1]))
		B += A
		if len(set(B)) == len(set(A)):
			print('IMPOSSIBLE')
		else:
			print('POSSIBLE')

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))
# import sys
# input = sys.stdin.readline

import fractions

N,K=two_int()

A=many_int()

if K <= max(A):
    temp=A[0]
    for a in A[1:]:
        temp = fractions.gcd(temp,a)

    if temp==K or temp==1:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE") 

else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k= map(int,input().split())
a = list(map(int,input().split()))
print(('' if k <= max(a) and (k in a or reduce(gcd, a) == 1) else 'IM') + 'POSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k= map(int,input().split())
a = list(map(int,input().split()))
print(('' if k < max(a) and (k in a or reduce(gcd, a) == 1) else 'IM') + 'POSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k= map(int,input().split())
a = list(map(int,input().split()))
print(('' if k in a or reduce(gcd, a) == 1 else 'IM') + 'POSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k= map(int,input().split())
a = list(map(int,input().split()))
print(('' if k not in a and reduce(gcd, a) == 1 else 'IM') + 'POSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k= map(int,input().split())
a = list(map(int,input().split()))
print(('' if reduce(gcd, a) == 1 else 'IM') + 'POSSIBLE')

Submission status: Wrong Answer

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

n,k=map(int,input().split())
a=list(map(int,input().split()))
x=max(a)
for i in range(1,n):
    a[0]=gcd(a[0],a[i])
if k%a[0]==0 and k<=x-a[0]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

n,k=map(int,input().split())
a=list(map(int,input().split()))
x=max(a)
for i in range(1,n):
    a[0]=gcd(a[0],a[i])
if k%a[0]==0 and k-a[0]<=x:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import fractions
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
maxa=max(a)
mindiff=a[0]
for i in range(len(a)-1):
	mindiff=fractions.gcd(mindiff,a[i])

a_more_k=[a[i] for i in range(len(a)) if a[i]>k]
for i in range(len(a_more_k)):
	if( (a_more_k[i]-k)%mindiff == 0):
		print("POSSIBLE")
		sys.exit()

print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd


def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


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

if K % greatest_common_divisor(A) != 0 or K <= max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd


def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


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

if K % greatest_common_divisor(A) != 0:
    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()

if A[-1] < K:
    print("IMPOSSIBLE")
    exit()

if K in A or 1 in A:
    print("POSSIBLE")
    exit()

def gcd(a,b):
    x = max([a,b])
    y = min([a,b])
    while y:
        x, y = y, x % y
    return x

for i in range(1,N):
    if gcd(A[i], A[0]) == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:

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

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

A.sort()

if A[-1] < K:
    print("IMPOSSIBLE")
    exit()




for i in range(1,N):
    if A[i] % A[0] != 0:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:

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

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

A.sort()

if A[-1] < K:
    print("IMPOSSIBLE")
    exit()

if K in A or 1 in A:
    print("POSSIBLE")
    exit()



for i in range(1,N):
    if A[i] % A[0] != 0:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import itertools


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

flag = 0
A_len = len(A)
# while K not in A:
#     for i in itertools.permutations(A, 2):
#         A.add(abs(i[0] - i[1]))
#     if A_len == len(A):
#         flag = 1
#         break
#     if 1 in A:
#         break

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

for i in itertools.permutations(A, 2):
    A.add(abs(i[0] - i[1]))
if A_len == len(A):
    print("IMPOSSIBLE")
    exit()

kisuu = []
gusuu = []

for a in A:
    if a % 2 == 0:
        gusuu.append(a)
    else:
        kisuu.append(a)

if K % 2 == 1 and len(kisuu) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
import itertools


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

flag = 0
for i in itertools.permutations(A, 2):
    if abs(i[0] - i[1]) not in A:
        print("POSSIBLE")
        flag = 1
        break

if flag == 0:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

n,k = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = gcd(ans,a[i])
m = max(a)
if ans <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:

import fractions
from functools import reduce

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


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

b = gcd_list(a)
if max(a) > k and k % b == 0:
    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()
for i in a:
    if i %2 != 0:
        odd = i
        break

if max(a) < k:
    print('IMPOSSIBLE')
elif k in a:
    print('POSSIBLE')
else:
    flag_u = False
    flag_d = True
    for i in a:
        if i % k == 0:
            flag_u = True
        elif k % i == 0:
            flag_d = True
    if flag_u is True and flag_d is True:
        print('POSSIBLE')
        exit()

    flag_e = False
    flag_o = False
    for i in a:
        if i %2 == 0:
            flag_e = True
        else:
            flag_o = True
    if flag_e is True and flag_o is True:
        for i in a:
            if i == odd:
                continue
            else:
                if i %2 == 0:
                    if i % odd != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
                else:
                    if i % odd != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
        print('IMPOSSIBLE')
        exit()
    elif flag_e is True:
        if k %2 == 0:
            print('POSSIBLE')
            exit()
        else:
            print('IMPOSSIBLE')
            exit()
    elif flag_o is True:
        for i in a:
            if i == min(a):
                continue
            else:
                if i % min(a) != 0:
                    print('POSSIBLE')
                    exit()
                else:
                    continue
        print('IMPOSSIBLE')
        exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in a:
    if i %2 != 0:
        odd = i
        break

if max(a) < k:
    print('IMPOSSIBLE')
elif k in a:
    print('POSSIBLE')
else:
    flag_e = False
    flag_o = False
    for i in a:
        if i %2 == 0:
            flag_e = True
        else:
            flag_o = True
    if flag_e is True and flag_o is True:
        for i in a:
            if i == odd:
                continue
            else:
                if i %2 == 0:
                    if (i-odd) % odd != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
                else:
                    if i % odd != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
        print('IMPOSSIBLE')
        exit()
    elif flag_e is True:
        if k %2 == 0:
            print('POSSIBLE')
            exit()
        else:
            print('IMPOSSIBLE')
            exit()
    elif flag_o is True:
        for i in a:
            if i == min(a):
                continue
            else:
                if i % min(a) != 0:
                    print('POSSIBLE')
                    exit()
                else:
                    continue
        print('IMPOSSIBLE')
        exit()

Submission status: Wrong Answer

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

if max(a) < k:
    print('IMPOSSIBLE')
elif k in a:
    print('POSSIBLE')
else:
    flag_e = False
    flag_o = False
    for i in a:
        if i %2 == 0:
            flag_e = True
        else:
            flag_o = True
    if flag_e is True and flag_o is True:
        for i in a:
            if i == min(a):
                continue
            else:
                if i %2 == 0:
                    if (i-min(a)) % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
                else:
                    if i % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
        print('IMPOSSIBLE')
        exit()
    elif flag_e is True:
        if k %2 == 0:
            print('POSSIBLE')
            exit()
        else:
            print('IMPOSSIBLE')
            exit()
    else:
        for i in a:
            if i == min(a):
                continue
            else:
                if i % min(a) != 0:
                    print('POSSIBLE')
                    exit()
                else:
                    continue
        print('IMPOSSIBLE')
        exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k>max(a):
    print('IMPOSSIBLE')
else:
    if k in a:
        print('POSSIBLE')
    else:
        a.sort()
        cnt=[]
        s=a[0]
        mi=100000000000
        for i in range(n):
            cnt.append(a[i]-s)
            s=a[i]
            if mi>abs(k-a[i]):
                mi=a[i]
        ans=0
        for j in range(n):
            if mi-cnt[j]==k or mi+cnt[j]==k:
                ans=1
        if ans==1:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import numpy as np


def calc(n, k, a):
    a = np.sort(a)
    if n == 1:
        res = "POSSIBLE" if a[0] == k else "IMPOSSIBLE"
        return res
    if k > a[-1]:
        return "IMPOSSIBLE"

    base = a[0]
    a[a % base != 0] = 0
    if np.all(a):
        res = "POSSIBLE" if k % base == 0 else "IMPOSSIBLE"
    else:
        res = "POSSIBLE"
    return res


if __name__ == "__main__":
    n, k = map(int, input().split())
    a = np.array(list(map(int, input().split())))
    ans = calc(n, k, a)
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,k=map(int,input().split())
g=0
for a in map(int,input().split()):
    if(k==a):
        print("POSSIBLE")
        exit()
    g=gcd(g,a)

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,k=map(int,input().split())
g=0
for a in map(int,input().split()):
    g=gcd(g,a)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
if k in a:
    print('POSSIBLE')
    quit()
if k > max(a):
    print('IMPOSSIBLE')
    quit()
a.sort()
tmp = a[1] - a[0]
for i in range(1,n-1):
    tmp = fractions.gcd(a[i+1]-a[i], tmp)
    if tmp == 1:
        break
if tmp == 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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

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

a=[int(x) for x in input().split()]
a.sort()
bb=set(a)
for i in range(n-1):
    tm=a[i+1]-a[i]
    bb.add(tm)
cv=list(bb)
cv.sort()

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

if max(cv)<k:
    print("IMPOSSIBLE")
    exit()

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

xc=0
cb=False
if cv[0]==1:
    xc=cv[1]

elif cv[0]==0:
    if cv[1]==1:
        xc=cv[2]
    else:
        xc=cv[1]
else:
    xc=cv[0]

for i in range(len(cv)):
    if cv[i]%xc!=0:
        cb=True

if k<=max(cv):
    if cb:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

print("IMPOSSIBLE")

Submission status: Wrong Answer

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

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
b=gcd(*a)
print(b)
if max(a)-k>=0 and (max(a)-k)%b==0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import math
from functools import reduce
import fractions as fr

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

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

c = int(gcd(*a))

for i in a:
  if i - k > 0 and (i-k) % c == 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))

b = []

if n == 1:
  if a[0] == k:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")
  sys.exit()

for i in range(len(a) - 1):
  b.append(abs(a[i]-a[i+1]))
  
c = int(np.min(b))

for i in a:
  if i - k > 0 and (i-k) % c == 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
s=A[1]-A[0]
if N==2:
    if K==A[0]-s:
        print("POSSIBLE")
        exit()
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
s=A[1]-A[0]
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
if K > maxA:
	print("IMPOSSIBLE")
	sys.exit()

if K in A:
	print("POSSIBLE")
	sys.exit()

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

for i in range(1,N):
	if i == 1:
		temp = GCD(A[0],A[1])
	else:
		temp = GCD(temp, A[i])

if temp == 1:
	ans = "POSSIBLE"
else:
	if K//temp == 0:
		ans = "POSSIBLE"
	else:
		ans = "IMPOSSIBLE"

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

g = reduce(gcd, A)
if K % g == 0:
    flag = True
else:
    flag = False

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

two = A % 2
three = A % 3
five = A % 5
seven = A % 7
flag = True
if K > A.max():
    flag = False
if len(set(two)) == 1 and two[0] != K%2:
    flag = False
if len(set(three)) == 1 and three[0] != K%3:
    flag = False
if len(set(five)) == 1 and five[0] != K%5:
    flag = False
if len(set(five)) == 1 and seven[0] != K%7:
    flag = False
print('POSSIBLE' if flag else 'IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

two = A % 2
three = A % 3
flag = True
if K > A.max():
    flag = False
if len(set(two)) == 1 and two[0] != K%2:
    flag = False
if len(set(three)) == 1 and three[0] != K%3:
    flag = False
print('POSSIBLE' if flag else '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 = A[-1]
for i in A[:-1]:
    g = gcd(g, i)

a = max(A)
if (a - K) % g == 0 and a > K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

def gcdd(*numbers):
    return reduce(gcd, numbers)

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

agcd = gcdd(*a)

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
def gcd(n,m):
  if n>m:
    a=n
    b=m
  else:
    a=m
    b=n
  while b!=0:
    a,b=b,a%b
  return a
g=l[0]
max=l[0]
for i in range(1,1+n-1):
  g=gcd(g,l[i])
  if max<l[i]:
    max=l[i]
if max>k:
  print("POSSIBLE")
elif max==k:
  print("POSSIBLE")
else:
  if k%g==0:
    print("POSSIBLE")
  else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))
    ww_list = set([w + K for w in w_list])
    if ww_list & set(w_list):
        return True, w_list
    else:
        return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            # 操作によって作れる差分よりKの方が大きいので
            # これ以上操作してもKを作れない
            break
        if w_list == org_w_list:
            # これ以上操作しても変化がない
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)

Submission status: Wrong Answer

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

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

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
N,K,*A=map(int,open(0).read().split())
print("IM"*(((K-A[0])%reduce(gcd,A)>0)&((min(A)>K)|(K>max(A))))+"POSSIBLE")

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]

if k>max(lista):
    print("IMPOSSIBLE")
else:
    flag = False
    for i in range(n):
         if lista[i]==k:
            flag = True
            print("POSSIBLE")
    if flag==False:
        
        lista.sort(reverse=True)
        listb=[]
        listc=[]
        for i in range(n):
            c=lista[i]-k
            if c>0:
                listc.append(c)
        
        for i in range(n):
            for j in range(1,n):
                    b=(lista[i])-(lista[j])
                    if b>0:
                        listb.append(b)
                        listb.sort
        
        print(listb)
        print(listc)

        for i in range(len(listc)):
            for j in range(len(listb)):
                if listc[i]%listb[j]==0:
                        flag = True
                        print("POSSIBLE")
                if flag:
                    break
            if flag:
                break
        if flag==False:
                    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

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

if N==1:
  print("POSSIBLE" if N==K else "IMPOSSIBLE")
else:
  if K in A:
    print("POSSIBL")
  else:
    if max(A)<K:
      print("IMPOSSIBLE")
    else:
      A.sort()
      B=[]
      for i in range(N-1):
        B.append(A[i+1]-A[i])
      #print(B)
      
      max_gcd=B[0]
      for i in range(1,len(B)):
        max_gcd=gcd(max_gcd,B[i])
      #print(max_gcd)
      
      C=[]
      for i in range(N):
        if A[i]-K>0:
          C.append(A[i]-K)
      #print(C)
      
      C=list(map(lambda x: x%max_gcd,C))
      #print(C)
      
      print("POSSIBLE" if min(C)==0 else "IMPOSSIBLE")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# li = list(map(int, input().split()))
N, K = map(int, input().split())
A_N = list(map(int, input().split()))


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


next = A_N[0]
for i in range(len(A_N)):
    next = gcd(A_N[i], next)

if K >= max(A_N):
    print('IMPOSSIBLE')
elif next == 1:
    print('POSSIBLE')
elif K % next ==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
# li = list(map(int, input().split()))
N, K = map(int, input().split())
A_N = list(map(int, input().split()))


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


next = A_N[0]
for i in range(len(A_N)):
    next = gcd(A_N[i], next)

if next == 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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

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

def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))

    gcd_ = a[0]
    for i in range(1, N):
        gcd_ = gcd(gcd_, a[i])
    
    if K%gcd_ == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
print('IMPOSSIBLE')