Problem:


Score : 300 points

Problem Statement

There is a box containing N balls. The i-th ball has the integer A_i written on it.
Snuke can perform the following operation any number of times:

Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written.

Determine whether it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written.

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9

1 \leq K \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

If it is possible for Snuke to reach the state where the box contains a ball on which the integer K is written, print POSSIBLE; if it is not possible, print IMPOSSIBLE.

Sample Input 1

3 7
9 3 4

Sample Output 1

POSSIBLE

First, take out the two balls 9 and 4, and return them back along with a new ball, abs(9-4)=5.
Next, take out 3 and 5, and return them back along with abs(3-5)=2.
Finally, take out 9 and 2, and return them back along with abs(9-2)=7.
Now we have 7 in the box, and the answer is therefore POSSIBLE.

Sample Input 2

3 5
6 9 3

Sample Output 2

IMPOSSIBLE

No matter what we do, it is not possible to have 5 in the box. The answer is therefore IMPOSSIBLE.

Sample Input 3

4 11
11 3 7 15

Sample Output 3

POSSIBLE

The box already contains 11 before we do anything. The answer is therefore POSSIBLE.

Sample Input 4

5 12
10 2 8 6 4

Sample Output 4

IMPOSSIBLE



Sample input:
3 7
9 3 4


Sample output:
POSSIBLE

Submission status: Accepted

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

def main():
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=a[0]
    for e in a:
        g=gcd(g,e)
        if m<e: m=e
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

array = list(set(array))

if len(array) == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)

Submission status: Accepted

Solution code:
n,k = map(int,raw_input().split())

arr = map(int,raw_input().split())
if k > max(arr):
	print "IMPOSSIBLE"
	quit()

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

g = arr[0]

for i in range(1,n):
	g = gcd(g,arr[i])

if k%g == 0 :
	print "POSSIBLE"

else :
	print "IMPOSSIBLE"

Submission status: Accepted

Solution code:
def findGCD(a:int, b:int) -> int:
    # ユークリッドの互除法
    while 1:
        if a%b == 0:
            return b
        else:
            a = a%b
        
        if b%a == 0:
            return a
        else:
            b = b%a
            
from functools import reduce

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


gcd = reduce(findGCD, a)

if k % gcd == 0 and k <= max(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
def findGCD(a:int, b:int) -> int:
    # バリデーション　a,bは0以上
    if a <= 0:
        raise ValueError("aは0より大きくなければいけません。(a:{})".format(a))
    elif b <= 0:
        raise ValueError("bは0より大きくなければいけません。(b:{})".format(b))
    
    # ユークリッドの互除法
    while 1:
        if a%b == 0:
            return b
        else:
            a = a%b
        
        if b%a == 0:
            return a
        else:
            b = b%a
            
from functools import reduce

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


gcd = reduce(findGCD, a)

if k % gcd == 0 and k <= max(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
n,k = map(int,input().split())

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

b = a[0]

for i in a:
    b = gcd(b,i)

if k > max(a) or k%b != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Accepted

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

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

from functools import reduce
g = reduce(gcd, a)

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

Submission status: Accepted

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

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

from functools import reduce

a = sorted(A)
d = reduce(gcd, a)

if (a[-1] >= K) and (a[-1] - K) % d == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)
 
def gcd_many(l):
    # if len(l) == 1:
    #     return l
    # elif len(l) == 2:
    #     return gcd(l[0], l[1])
    # else:
    #     return gcd(l[0], gcd_many(l[1:]))
    if len(l) == 1:
        return l[0]
    g = l[0]
    for i in range(1,len(l)):
        g = gcd(g, l[i])
    return g
 
Amax = max(A)
g = gcd_many(A)
 
possible = "POSSIBLE"
impossible = "IMPOSSIBLE"
 
 
if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)

Submission status: Accepted

Solution code:
from fractions import gcd

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

if n == 1:
	if a[0] == 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: Accepted

Solution code:
from fractions import gcd
N,K=map(int,input().split())
A=[int(i) for i in input().split()]

def f(L):
    if N==1:
        return L[0]
    else:
        a = gcd(L[0],L[1])
        for i in range(2,N):
            a = gcd(a,L[i])
        return a

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

Submission status: Accepted

Solution code:
#AGC018 A
import fractions

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

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

if K in A:
    print("POSSIBLE")
elif K<=MAX:
    GCD = A[0]
    for a in A[1:]: GCD = fractions.gcd(GCD,a)
    if K%GCD==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
def a_getting_difference(N, K, A):
    import fractions # 3.5以降はmath.gcd()を使う
    gcd_a = A[0]
    max_a = max(A)
    for i in range(1, N):
        gcd_a = fractions.gcd(gcd_a, A[i])

    ans = 'POSSIBLE' if K <= max_a and K % gcd_a == 0 else 'IMPOSSIBLE'
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(a_getting_difference(N, K, A))

Submission status: Accepted

Solution code:
import fractions
import sys

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == 1:
    print("POSSIBLE" if max(array) == k else "IMPOSSIBLE")
    sys.exit()

res = fractions.gcd(array[0], array[1])

for i in array[2:]:
    res = fractions.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")

Submission status: Accepted

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

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

def gcd(a, b):
    if a > b:
        a, b = b, a
    # assert(a <= b)
    if b%a == 0:
        return a
    else:
        return gcd(b%a, a)

def gcd_many(l):
    # if len(l) == 1:
    #     return l
    # elif len(l) == 2:
    #     return gcd(l[0], l[1])
    # else:
    #     return gcd(l[0], gcd_many(l[1:]))
    if len(l) == 1:
        return l[0]
    g = l[0]
    for i in range(1,len(l)):
        g = gcd(g, l[i])
    return g

Amax = max(A)
g = gcd_many(A)

possible = "POSSIBLE"
impossible = "IMPOSSIBLE"


if K > Amax:
    print(impossible)
else:
    if K % g == 0:
        print(possible)
    else:
        print(impossible)

Submission status: Accepted

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: Accepted

Solution code:
def gcd(a0, b0):
    a, b = max(a0, b0), min(a0, b0)
    while b != 0:
        a = a % b
        a, b = b, a

    return a


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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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: Accepted

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


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


if max(A) < K:
    print("IMPOSSIBLE")
    exit()
elif K in A:
    print("POSSIBLE")
    exit()

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

if K % A[0] == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from functools import reduce

import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

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

    gcd_ = reduce(gcd, A)
    if max(A) >= K and not K % gcd_:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

main()

Submission status: Accepted

Solution code:
tmp = list(map(int,input().split()))
n , m = tmp[0],tmp[1]
lis = list(map(int,input().split()))
import math
def gcd(a,b):
  if a % b:
    return(gcd(b,a%b))
  else:
    return(b)
  
from functools import reduce

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

x = mygcd(*lis)
if m <= max(lis) and not (m % x):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd
n, k = map(int,input().split())
balls = list(map(int,input().split()))
balls.sort()
p = max(balls)
if k in balls:
    print("POSSIBLE")
    exit()
elif  p < k:
    print("IMPOSSIBLE")
    exit()
for i in range(n-1):
    p = gcd(p, balls[i])
if k % p == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd

n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
b=a[0]
for i in range(1,n):
  b=gcd(b,a[i])

if c > a[n-1]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if c % b==0 else "IMPOSSIBLE")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=max(A)
cnt=ans
for i in range(N):
  cnt=gcd(cnt,A[i])

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

Submission status: Accepted

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


# 最大公約数
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 K % A[0] == 0 and any(map(lambda x: x >= K, B)):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def gcd(x, y):
    if x < y:
        x, y = y, x  # x >= y
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def gcd_all(a):
    g = a[0]
    for y in a:
        g = gcd(g, y)
    return g

def main():
    n, k = map(int, input().split())
    ai = list(map(int, input().split()))
    assert len(ai) == n
    g = gcd_all(ai)
    m = max(ai)
    if m - k >= 0 and (m - k) % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

Submission status: Accepted

Solution code:
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a.sort()
for i in range(a[0],0,-1):
	if a[0]%i==0:
		if all(a[j]%i==0 for j in range(n)):
			num = i
			break
if k%num==0 and k<=a[-1]: print("POSSIBLE")
else: print("IMPOSSIBLE")

Submission status: Accepted

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

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

G = A[0]
for A_i in A:
    G = gcd(A_i, G)

if K > max(A):
    print('IMPOSSIBLE')
elif K % G == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import math
def gcd(a,b):
    c=max([a,b])
    d=min([a,b])
    if c%d==0:
        return d
    else:
        return gcd(d,c%d)
N,K=map(int, input().split())
A=[int(i) for i in input().split()]
if max(A)<K:
    print("IMPOSSIBLE")
else:
    G=A[0]
    for i in range(1,N):
        G=gcd(G,A[i])
    if K%G==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

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

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

min_A = A[0]
for i in range(1,N):
    if A[i]-A[i-1] != 0:
        min_A = min(min_A,A[i]-A[i-1])

for j in range(N):
    if A[j]%min_A != 0:
        print("POSSIBLE")
        exit()
if K % min_A == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
*A, = map(int, input().split())
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])

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

Submission status: Accepted

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


mod=functools.reduce(gcd,A)

tmp=0
if max(A)>=K and K%mod==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import fractions


N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit()
temp = A[0]
for a in A:
    temp = fractions.gcd(temp, a)
if temp == 1:
    if K <= max(A):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    if K > max(A):
        print("IMPOSSIBLE")
    elif K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

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

Submission status: Accepted

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

input1 = list(map(int,input("").split(" ")))
A = list(map(int,input("").split(" ")))
N = input1[0]
K = input1[1]

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


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


def solve(N, K, A_list):
    A_list = list(sorted(A_list))
    if max(A_list) < K:
        return False

    if K in A_list:
        return True

    x = A_list[0]
    min_d = INF
    for a in A_list:
        min_d = min(min_d, gcd(a, x))

    for a in A_list:
        if a > K and (a - K) % min_d == 0:
            return True
    return False


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

    print("POSSIBLE" if solve(N, K, A_list) else "IMPOSSIBLE")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solve():
    n, k = list(map(int, input().strip().split()))
    a = list(map(int, input().strip().split()))

    m = a[0]
    maxx = a[0]
    for i in range(1, n):
        m = gcd(m, a[i])
        if a[i] > maxx:
            maxx = a[i]

    if k % m == 0 and k <= maxx:
        return "POSSIBLE"
    else:
        return "IMPOSSIBLE"

print(solve())

Submission status: Accepted

Solution code:
"""
    Author        : Arif Ahmad
    Date          :
    Algo          :
    Difficulty    :
"""
from sys import stdin, stdout
from fractions import gcd


def main():
    n, k = [int(_) for _ in stdin.readline().strip().split()]
    a = [int(_) for _ in stdin.readline().strip().split()]

    g = a[0]
    for x in range(1, n):
        g = gcd(g, a[x])

    if k % g == 0 and k <= max(a):
        stdout.write('POSSIBLE\n')
    else:
        stdout.write('IMPOSSIBLE\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def gcd(n,m):
    if n < m:
        tmp = n
        n = m
        m = tmp
    while n % m != 0:
        tmp = m
        m = n % m
        n = tmp
    return m
g = M
for a in A:
    g = gcd(g,a)
    if g == 1:
        break
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
#AGC018A

from fractions import gcd
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
g=a[0]
for i in xrange(n):
 g=gcd(g,a[i])
if k<=max(a) and k%g==0:
 print 'POSSIBLE'
else:
 print 'IMPOSSIBLE'

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
arr = map(int, raw_input().split())

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

cur = arr[0]
for x in arr:
    cur = gcd(cur, x)

if k % cur == 0 and k <= max(arr):
    print "POSSIBLE"
else:
    print "IMPOSSIBLE"

Submission status: Accepted

Solution code:
from fractions import gcd
 
 
def get_difference():
	# get input from raw_input()
	n, k = map(int, raw_input().split(' '))
	l = [int(e) for e in raw_input().split(' ')]
	if k in l:
		print "POSSIBLE"
		return
	if k>max(l):
		print "IMPOSSIBLE"
		return
	gcd_v = reduce(gcd, l)
	if k%gcd_v==0:
		print "POSSIBLE"
	else:
		print "IMPOSSIBLE"
 
 
if __name__ == "__main__":
	get_difference()

Submission status: Accepted

Solution code:
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))
 
M = max(A)
G = reduce(gcd, sorted(A))
 
if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

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

Submission status: Accepted

Solution code:
import fractions

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

if n==1:
    ans=a[0]
elif n==2:
    ans=fractions.gcd(a[0],a[1])

else:
    ans=fractions.gcd(a[0],a[1])
    for i in range(2,n):
        ans=fractions.gcd(ans,a[i])

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

Submission status: Accepted

Solution code:
N,K=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
def gcd(a,b):
    a,b=min(a,b),max(a,b)
    if b%a==0:
        return a
    else:
        return gcd(a,b%a)
#assume len(A)>1    
def findgcd(A):
    ans=gcd(A[0],A[-1])
    for i in range(len(A)):
        ans=gcd(ans,A[i])
        if ans==1:
            return 1
    return ans
ans=findgcd(A)
good=0
if N>1:
    for i in range(len(A)):
        if A[i]==K:
            good=1
            break
        elif A[i]>K:
            if (A[i]-K)%ans==0:
                good=1
                break
else:
    if A[0]==K:
        good=1
if good==1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import fractions 
length,target = (int(n) for n in raw_input().split(" "))
ball = [int(n) for n in raw_input().split(" ")]
gcd = ball[0]
for i in range(1,length):
    gcd = fractions.gcd(gcd,ball[i])
if target % gcd == 0 and target <= max(ball):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n,k = rli()
A = rli()

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

b = 0
for a in A:
    b  = gcd(a, b)

if k%b or k > max(A):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Submission status: Accepted

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

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

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

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

Submission status: Accepted

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

n,k = map(int, raw_input().split())
l = map(int, raw_input().split())
g = l[0]
idx = 1
while idx < n:
    g = gcd(g,l[idx])
    idx += 1
if k <= max(l) and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Submission status: Accepted

Solution code:
import functools as ft

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

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

	max_num = max(nums)
	g = ft.reduce(lambda x, y: gcd(x, y), nums)

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

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def gcd(u, v):
    while v:
        u, v = v, u % v
    return u

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

g = 0
for i in A:
    g = gcd(i, g)

if K % g or K > max(A):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd
N, K = map(int, raw_input().split(' '))
A = map(int, raw_input().split(' '))

M = max(A)
G = reduce(gcd, sorted(A))

if not K % G and K <= M:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

Submission status: Accepted

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

def gcd_list(lst):
    g = lst[0]
    for i in range(1,len(lst)):
        g = gcd(g,lst[i])
    return g
    
n, k = (int(i) for i in input().split())
a = list(int(i) for i in input().split())  

maxA=max(a)

if (k <= maxA and k%gcd_list(a) == 0) or (k in a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = list(map(int, input().split()))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM

print(ans)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = sorted(list(map(int, input().split())))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])

if K%g==0:
	ans=PO
else:
	ans=IM


print(ans)

Submission status: Accepted

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


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

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

if (k < max(a) and k%g == 0) or (k in a) :
    print('POSSIBLE')
else :
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

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

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

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

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]

    input_raw = list(read_func().strip().split())
    A = set([])
    for i in range(len(input_raw)):
        A.add(int(input_raw[i]))
    A_list = list(A)
    possible_flag = False
    is_all_geometric = False

    if len(filter(lambda x:x >=K , A)) != 0:
        g = A_list[0]
        for i in range(1, len(A_list)):
            x = A_list[i]
            if x == K:
                possible_flag = True
                break
            g = gcd(g, A_list[i])

        if g == 1:
            possible_flag = True
        elif K % g == 0 :
            possible_flag = True

    if possible_flag == True:
        print "POSSIBLE"
    else:
        print "IMPOSSIBLE"


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import fractions
N,K=map(int,input().split())
A=sorted(list(set(map(int,input().split()))))
N=len(A)
if N==1:
  print("POSSIBLE" if A[0] == K else "IMPOSSIBLE")
  sys.exit(0)
g=A[1]-A[0]
for i in range(1,len(A)-1):
  g = fractions.gcd(A[i+1]-A[i], g)
if K <= A[N-1] and (K-A[0]) % g == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
import fractions

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))


n, k = rli()
a = rli()
if(max(a) < k):
    print("IMPOSSIBLE")
else:
    g = a[0]
    for i in a[1:]:
        g = fractions.gcd(g, i)
    if(k % g == 0):
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from sys import stdin
from fractions import gcd
n, k = map(int, stdin.readline().split())
a = map(int, stdin.readline().split())
g = a[0]
for x in a:
    g = gcd(g, x)
m = max(a)
if k > m or (m - k) % g:
    print "IMPOSSIBLE"
else:
    print "POSSIBLE"

Submission status: Accepted

Solution code:
import random
import fractions

def solve(N, K, A):
    gcd = A[0]
    for x in A:
        gcd = fractions.gcd(gcd, x)
    if K % gcd == 0 and max(A) >= K:
        return 'POSSIBLE'
    else:
        return 'IMPOSSIBLE'

def solve2(N, K, A):
    mx = max(A)
    B = [False] * (mx + 1)
    for i in A:
        B[i] = True
    while True:
        update = False
        for i in range(mx + 1):
            if not B[i]:
                continue
            for j in range(i + 1, mx + 1):
                if not B[j]:
                    continue
                d = abs(i - j)
                if not B[d]:
                    update = True
                    B[d] = True
        if not update:
            break
    return 'POSSIBLE' if K <= mx and B[K] else 'IMPOSSIBLE'

#for i in range(100000):
#    N = random.randint(1, 5)
#    K = random.randint(1, 20)
#    A = [random.randint(1, 20) for i in range(N)]
#    if solve(N, K, A) != solve2(N, K, A):
#        print(N, K, A)
#        print(solve(N, K, A))
#        print(solve2(N, K, A))
#        break

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