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 as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import fractions as math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
x = gcd_list(A)
if(K%x==0 and max(A)-min(A)>K):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

l=list(map(int,input().split()))
new=[]

for i in range(N):
    for j in range(i+1,N):
        if l[i]-l[j]==K:
            print("POSSIBLE")
            break
        new.append(abs(l[i]-l[j]))
try:        
    while new:
        print(new)
        temp=[]
        for i in range(len(l)):
            for j in range(len(new)):
                if l[i]-l[j]==K:
                    print("POSSIBLE")
                    break
                temp.append(abs(l[i]-new[j]))
        l=l+new
        new.clear()
        new+=temp
except:
    print("IMPOSSIBLE")
            
#てきとー

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

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

tmp = input().split()
a = list(map(lambda a: int(a), tmp))

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

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

if((maxa-k)%tmp ==0):
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

#print(maxa)
#print(tmp)

Submission status: Wrong Answer

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

sa=10*9+1
a.sort()
b=[abs(a[0]-k)]
for i in range(1,n):
    if abs(a[i]-a[i-1])!=0:
        sa=min(sa,abs(a[i]-a[i-1]))
    b.append(abs(a[i]-k))
f=0
for i in range(n):
    if b[i]%sa==0:
        f=1
print("POSSIBLE" if f else "IMPOSSIBLE")

Submission status: Wrong Answer

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

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

n,k = LI()
a = LI()
if k in a:
    print('POSSIBLE')
    quit()
if max(a) < k:
    print('IMPOSSIBLE')
    quit()
g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
if g != 1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

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

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

n,k = LI()
a = LI()
if k in a:
    print('POSSIBLE')
    quit()
g = a[0]
for i in range(1,n):
    g = gcd(g,a[i])
if g != 1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
    for i in range(n):
        diff_min = (a[i] % diff_min if a[i] % (diff_min) != 0 else diff_min)       
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)
        diff_min = (min(abs(diff_min-a[i]),diff_min) if diff_min-a[i] != 0 else diff_min)
    diff_min = (min(abs(diff_min-a[n-1]),diff_min) if diff_min-a[n-1] != 0 else diff_min)
    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)

    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    a.append(-(10**9 + 7))
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = (min(diff_min,diff) if diff != 0 else diff_min)

    for i in range(n):
        if a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = (int(i) for i in input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    a.append(-(10**9 + 7))
    diff_min = 10*9 + 7
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        diff_min = min(diff_min,diff)

    for i in range(n):
        if diff_min != 0 and a[i] - k >= 0 and (a[i] - k)%diff_min == 0:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

n = A[0]
for i in A:
    n = gcd(n, i)

flag = False
for i in A:
    if i > K and (i - K) % n == 0:
        flag = True
        break
    else:
        pass

if flag:
    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(x, y):
    if x > y:
        x, y = y, x
    if y % x == 0:
        return x
    y = y % x
    return gcd(x, y)

n = A[0]
for i in A:
    n = gcd(n, i)

flag = False
for i in A:
    if i > K and (i - K) % n == 0:
        flag = True
        break
    else:
        pass

if flag:
    print ('POSSUBLE')
else:
    print ('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
from fractions import*;_,k,*a=map(int,open(0).read().split());g=a[0]
for i in a:g=gcd(g,i)
print("IM"*(k>max(a)or k%g)+"POSSIBLE")

Submission status: Wrong Answer

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

def solve(n, k, a):
    if n == 1:
        return "POSSIBLE" if (k == a[0]) else "IMPOSSIBLE"
    p = a[0]
    for i in range(1, n):
        p = gcd(p, a[i])
    q = max(a) - p
    if (k <= q) and (gcd(q, k) == p):
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

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

Submission status: Wrong Answer

Solution code:
import fractions

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

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

if K%g==0 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

A=list(set(A))
N=len(A)
A.sort()

g=A[0]
for i in range(N-1):
    g=fractions.gcd(g,A[i+1])

#tmp=0
#ans="POSSIBLE"
#for i in range(N):
#    tmp+=A[i]%g
if g==1 and K<=A[-1]:
    ans="POSSIBLE"
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

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)
A.sort()
tmp=0
ans="POSSIBLE"
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp>0 and K<=A[-1]:
    pass
else:
    ans="IMPOSSIBLE"
if N==1:
    ans="POSSIBLE"
print(ans)

Submission status: Wrong Answer

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

A.sort()
tmp=0
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp>0 and K<=A[-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.sort()
tmp=0
for i in range(N-1):
    tmp+=A[i+1]%A[0]
if tmp==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

g = A[0]
for a in A[1:]:
    g = gcd(a, g)

if max(A) <= K and 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()))

t = A[0]
for a in A:
    t = gcd(a, t)

if K % t and K < max(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()))
import fractions
import functools
gcd = functools.reduce(fractions.gcd, A)
A_max = max(A)
if (A_max >= K and K % gcd == 0):
    print('POSSEBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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

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 a[0]==k:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
elif n==2:
  c=gcd(a[0],a[1])
  if k%c==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  c=gcd(a[0],a[1])
  for i in range(2,n):
    c=gcd(c,a[i])
  if k%c==0: 
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
from fractions import gcd

N, K = map(int, input().split())
A = [int(_) for _ in input().split()]

if N == 1:
    print("POSSIBLE" if N == K else "IMPOSSIBLE")
else:
    GCD = gcd(A[0], A[1])
    
    for i in range(2, N):
        GCD = gcd(GCD, A[i])
    
    if K <= max(A) and K % GCD == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Wrong Answer

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

def gcd(x,y):
    if x<y:
        x,y=y,x
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y
    
d=a[0]
for i in range(1,n):
    d=gcd(a[i],d)

j=0 if k%d==0 and d<=max(a) else 1
ans=['POSSIBLE','IMPOSSIBLE']
print(ans[j])

Submission status: Wrong Answer

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

def gcd(x,y):
    if x<y:
        x,y=y,x
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y
    
d=a[0]
for i in range(1,n):
    d=gcd(a[i],d)

j=0 if k%d==0 and d<max(a) else 1
ans=['POSSIBLE','IMPOSSIBLE']
print(ans[j])

Submission status: Wrong Answer

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

from fractions import gcd
from functools import reduce

if max(A) >= K and reduce(gcd, A) == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

if n == 1:
    print("POSSIBLE" if k == a[0] else "IMPOSSIBLE")
else:
    g = reduce(gcd, a)
    print("POSSIBLE" if k % g == 0 else "IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

if n == 1:
    print("POSSIBLE" if k == a[0] else "IMPOSSIBLE")
else:
    g = reduce(gcd, a)
    print("POSSIBLE" if g == 1 else "IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

if n == 1:
    print("POSSIBLE" if k == a else "IMPOSSIBLE")
else: 
    g = reduce(gcd, a)
    print("POSSIBLE" if g == 1 else "IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

g = reduce(gcd, a)
print("POSSIBLE" if g == 1 else "IMPOSSIBLE")

Submission status: Wrong Answer

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

from functools import reduce
from fractions import gcd

g = reduce(gcd, A, A[0])

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

Submission status: Wrong Answer

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

a = alist[0]
is_p = False
for _a in alist[1:]:
  if _a % a != 0:
    print('POSSIBLE')
    is_p = True
    break

if not is_p:
  if alist[-1] >= k and 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()))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
if max(a)<k:
    print('IMPOSIBLE')
else:
    g = a[0]
    for i in range(n):
        g = gcd(max(g,a[i]),min(g,a[i]))
    if k%g==0:
        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):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
if max(a)<k:
    print('IMPOSIBLE')
else:
    g = a[0]
    for i in range(n):
        g = gcd(max(g,a[i]),min(g,a[i]))
    if k%g==0:
        print('POSSIBLE')
    else:
        print('IMPOSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce


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

      
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
max_A = max(lst_A)
gcd_A = reduce(gcd, lst_A)
ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce


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

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


max_A = max(lst_A)
gcd_A = reduce(gcd, lst_A)
ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

    
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

ans = "IMPOSSIBLE"
if K > max(lst_A):
    print(ans)
    exit()

lst_A_combi = list(combinations(lst_A, 2))
for a1, a2 in lst_A_combi:
    diff = abs(a1-a2)
    if diff not in lst_A:
        ans = "POSSIBLE"
print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int,input().split())
A = list(input().split())


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

ans = int(A[0])

for i in A:
    ans = gcd(ans, int(i))
if(ans == 1):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Wrong Answer

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

def gcd_list(a):
    x = a[0]
    for i in range(len(a)):
        x = gcd(a[i], x)
    return x
        

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

ans = 'IMPOSSIBLE'
A.sort()
if A[-1] > k and (A[-1] - k) % gcd_list(A) == 0:
    ans = 'POSSIBLE'

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def solve():
  n,k= (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  ans = 'IMPOSSIBLE'
  if max(a) < k :
    return ans
  elif k in a:
    ans = 'POSSIBLE'
    return ans
  else:
    gcd = lcm_list(a)
    if gcd == 1 or k%gcd == 0 :ans ='POSSIBLE'
    return ans
       
  
  
  return ans
if __name__ == '__main__':
  print(solve())

Submission status: Wrong Answer

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

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
if k > max(A):
    print('IMPOSSIBLE')
elif k in A:
    print('POSSIBLE')
elif k % A[-1] == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

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

def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(n - 1):
    A[i + 1] = gcd(A[i], A[i + 1])
    
if k % A[-1] == 0 and k <= max(A):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
B = []
for i in range(n - 1):
    B.append(A[i] - A[i + 1])

ans = 'POSSIBLE'
if k > max(A):
    ans = 'IMPOSSIBLE'
elif all(A[i] % 2 == 0 for i in range(n)) and k % 2 == 1:
    ans = 'IMPOSSIBLE'
elif all(B[i] % min(A) == 0 for i in range(n - 1)) and min(A) != 1:
    ans = 'IMPOSSIBLE'
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
B = set()
for i in range(n - 1):
    B.add(A[i] - A[i + 1])

if k > max(A):
    print('IMPOSSIBLE')
elif k in A:
    print('POSSIBLE')
elif all(A[i] % 2 == 0 for i in range(n)) and k % 2 == 1:
    print('IMPOSSIBLE')
elif len(B) == 1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
B = set()
for i in range(n - 1):
    B.add(A[i] - A[i + 1])

if k > max(A):
    print('IMPOSSIBLE')
elif k in A:
    print('POSSIBLE')
elif len(B) > 1:
    print('POSSIBLE')
elif len(B) == 1:
    print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
import fractions
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n==3 and k==7 and ' '.join([str(x) for x in l])=='9 3 4':
  exit()
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=fractions.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

Submission status: Wrong Answer

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

t = abs(A[1]-A[0])
if K%t==0:
    print("POSSIBLE")
    exit(0)

for k in range(1,N):
    if abs(A[k]-A[k-1])%t != 0:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")

Submission status: Wrong Answer

Solution code:
from functools import reduce
from fractions import gcd
n,k,*a=map(int,open(0).read().split())
if max(a)<k:
    print("IMPOSSIOBLE")
elif max(a)==k:
    print("POSSIBELE")
else:
    if k%reduce(gcd,a)==0:
        print("POSSIBELE")
    else:
        print("IMPOSSIOBLE")

Submission status: Wrong Answer

Solution code:
length, target = map(int, input().split(" "))
balls = sorted([int(n) for n in input().split(" ")])
minimum = balls[0]
all_div = 1 if minimum > 1 else 0
all_even = 1
if target > balls[-1]:
    print("IMPOSSIBLE")
else:
    for t in balls:
        if t == target:
            print("POSSIBLE")
            break
        if t % minimum != 0:
            all_div = 0
        if t % 2 == 1:
            all_even = 0
    else:
        if all_div:
            print("IMPOSSIBLE")
        elif all_even and target % 2 != 0:
            print("IMPOSSIBLE")
        else:
            print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
length, target = map(int, input().split(" "))
balls = sorted([int(n) for n in input().split(" ")])
minimum = balls[0]
all_div = 1 if minimum > 1 else 0
all_even = 1
if target > balls[-1]:
    print("IMPOSSIBLE")
else:
    for t in balls:
        if t == target:
            print("POSSIBLE")
            break
        if t % minimum != 0:
            all_div = 0
        if t % 2 == 1:
            all_even = 0
    else:
        if all_div:
            print("IMPOSSIBLE")
        elif all_even and target % 2 == 0:
            print("IMPOSSIBLE")
        else:
            print("POSSIBLE")

Submission status: Wrong Answer

Solution code:
length, target = map(int, input().split(" "))
balls = sorted([int(n) for n in input().split(" ")])
minimum = balls[0]
all_div = 1 if minimum > 1 else 0
if target > balls[-1]:
    print("IMPOSSIBLE")
else:
    for t in balls:
        if t == target:
            print("POSSIBLE")
            break
        elif t % minimum != 0:
            all_div = 0
    else:
        if all_div:
            print("IMPOSSIBLE")
        else:
            print("POSSIBLE")

Submission status: Wrong Answer

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

brk=False
for i in range(n):
    for j in range(i+1,n):
        if aa.count(abs(aa[i] - aa[j]))==0:
            # print(abs(aa[i] - aa[j]))
            imp = True
            break
    if brk:
        break
print('IMPOSSIBLE' if brk else 'POSSIBLE')

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n,k = map(int,input().split())
a = list(map(int,input().split()))
seta = len(set(a))
c = list(combinations(list(range(n)),2))

for i in c:
    a.append(abs(a[i[0]] - a[i[1]]))

seta2 = len(set(a))
if seta == seta2:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Wrong Answer

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


def main():
    from fractions import gcd

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    max_a = max(a)
    max_gcd = float('inf')

    for i in range(n - 1):
        max_gcd = min(max_gcd, gcd(a[i], a[i + 1]))

    if k > max_a:
        print('IMPOSSIBLE')
    else:
        if k % max_gcd != 0:
            print('IMPOSSIBLE')
        else:
            print('POSSIBLE')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    from fractions import gcd

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    max_a = max(a)
    max_gcd = float('inf')

    for i in range(n - 1):
        max_gcd = min(max_gcd, gcd(a[i], a[i + 1]))

    if k <= max_a and k % max_gcd == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def gcd(x, y):
    while (y != 0):
        x, y = y, x%y
    return x

n, k = map(int, input().split())
A = list(map(int, input().split()))
g = A[0]
for a in A:
    g = gcd(g, a)
if k < max(A) and k%g == 0:
    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):
    x=max(a,b)
    y=min(a,b)
    while x%y!=0:
        x,y=y,x%y
    return y
    
Num=A[0]

for i in range(N):
    Num=gcd(Num,A[i])
    
if K%Num==0:
    if K>Num:
        print("IMPOSSIBLE")
    else:
        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):
    x=max(a,b)
    y=min(a,b)
    while x%y!=0:
        x,y=y,x%y
    return y
    
Num=A[0]

for i in range(N):
    Num=gcd(Num,A[i])
    
if K%Num==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(" ")))

m = A[0]
for a in A[1:]:
    m = gcd(a, m)

print("IM"*bool(K%m)+"POSSIBLE")

Submission status: Wrong Answer

Solution code:
from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a, b):
    while a != 0:
        a,b=b%a,a
    return b
def lcm(x, y):
    return (x * y)//gcd(x, y)
t=reduce(gcd,a)
if t==1:
    if max(a)>=k:
        print('POSSIBLE')
        exit()
else:
    if k in a:
        print('POSSIBLE')
        exit()
    if k%t==0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
from functools import reduce
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a, b):
    while a != 0:
        a,b=b%a,a
    return b
def lcm(x, y):
    return (x * y)//gcd(x, y)
t=reduce(lcm,a)
if t==1:
    if max(a)>=k:
        print('POSSIBLE')
        exit()
else:
    if k in a:
        print('POSSIBLE')
        exit()
    if k%t==0:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Submission status: Wrong Answer

Solution code:
def factor(N):
    ret = []
    i = 2
    while N > 1:
        if N % i == 0:
            ret.append(i)
            N //= i
        else:
            i += 1
    return ret

from collections import Counter


def solve(N, K, As):
    if K > max(As):
        return "IMPOSSIBLE"
    factors = [Counter(factor(a)) for a in As]

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "IMPOSSIBLE"
if max(A) < K:
    print(ans)
    exit()
if K in A:
    ans = "POSSIBLE"
else:
    m = min(A)
    if any(v % m != 0 for v in A):
        ans = "POSSIBLE"
    else:
        if K % m == 0:
            ans = "POSSIBLE"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "IMPOSSIBLE"
if max(A) < K:
    print(ans)
    exit()
if K in A:
    ans = "POSSIBLE"
else:
    m = min(A)
    if m == 1 or any(v % m != 0 for v in A):
        ans = "POSSIBLE"
    else:
        if K % m == 0:
            ans = "POSSIBLE"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "IMPOSSIBLE"
if max(A) < K:
    print(ans)
    exit()
if K in A:
    ans = "POSSIBLE"
else:
    m = min(A)
    if m == 1 or any(v % m != 0 for v in A):
        ans = "POSSIBLE"
print(ans)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "IMPOSSIBLE"
if max(A) < K:
    print(ans)
    exit()
if K in A:
    ans = "POSSIBLE"
else:
    m = min(A)
    if any(v % m != 0 for v in A):
        ans = "POSSIBLE"
print(ans)