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:
import numpy as np
import fractions

gcd_ufunc = np.frompyfunc(fractions.gcd, 2, 1)

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

G = gcd_ufunc.accumulate(A, dtype=np.object).astype(np.int)[-1]
M = max(A)

if K % G == 0 and K <= M:
    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()))

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

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

Submission status: Accepted

Solution code:
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int max = 0;
		int gcd = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			max = Math.max(max, a);
			gcd = gcd(gcd, a);
		}
		if (k <= max && k % gcd == 0)
			System.out.println("POSSIBLE");
		else
			System.out.println("IMPOSSIBLE");
	}
	static int gcd(int a, int b) {
		if(b == 0) return a;
		return gcd(b, a%b);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

Submission status: Accepted

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

Submission status: Accepted

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

def lcm(x, y):
    return x if y == 0 else lcm(y, x % y)

l = ar[0]
for a in ar[1:]:
    l = lcm(l, a)

ans = 'POSSIBLE' if k % l == 0 and k <= ar[-1] else 'IMPOSSIBLE'
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
g=0
for i in a:
    g=gcd(g,i)
if k>max(a):
    print("IMPOSSIBLE")
else:
    for i in a:
        if k%g==i%g:
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
ans=a[0]
for i in a:
    ans=gcd(ans,i)

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    d = A[i] - A[i+1]
    if d != 0:
        dif.append(d)
if dif:
    mind = min(dif)
else:
    mind = A[0]

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
from functools import reduce
def g(l):
  return reduce(gcd,l)
if max(a)<k:
  print('IMPOSSIBLE')
else:
  z=g(a)
  if k in a or k%z==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Accepted

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 or k%g!=0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Submission status: Accepted

Solution code:
def gcd(m, n):
    if m < n:
        return gcd(n, m)
    elif n == 0:
        return m
    return gcd(n, m % n)

def gcd_list(lst):
    ans = lst[0]
    for e in lst:
        ans = gcd(ans, e)
    return ans

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

if K <= max(A) and K % gcd_list(A) == 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')
elif 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: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
  print('POSSIBLE')
elif K > max(A):
  print('IMPOSSIBLE')
else:
  A_gcd = A[0]
  for i in range(1, N):
    A_gcd = gcd(A_gcd, A[i])

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

Submission status: Accepted

Solution code:
import sys
import fractions
import numpy as np


def main():
    n, k = [int(e) for e in input().split()]
    an = [int(e) for e in input().split()]
    an.sort(reverse=True)
    gcd = an[0]
    for a in an:
        gcd = fractions.gcd(a, gcd)
    if an[0] < k or (an[0] - k) % gcd != 0:
        print("IMPOSSIBLE")
    else:
        print("POSSIBLE")


main()

Submission status: Accepted

Solution code:
from fractions import gcd

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

if N == 1:
    print("POSSIBLE" if K == A[0] 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: Accepted

Solution code:
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
if len(A)==1:
    if A[0]==K:print("POSSIBLE")
    else:print("IMPOSSIBLE")
    exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
*A, = map(int, input().split())
A = sorted(A)
if K in A:
    print('POSSIBLE')
else:
    temp = [A[i+1] - A[i] for i in range(N-1) if A[i+1] - A[i] > 0]
    diff = min(temp) if temp else -1
    if diff == -1:
        print('IMPOSSIBLE')
    else:
        for a in [a for a in A if a >= K]:
            if (a - K) % diff == 0:
                print('POSSIBLE')
                break
        else:
            print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = max(a)
g = min(a)
for t in a:
  g = gcd(g,t)

if k%g == 0 and k <= m:
  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()))
m = max(a)
g = a[0]
for t in a:
  g = gcd(g,t)

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

Submission status: Accepted

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


num_balls, final_int = map(int,input().split())
balls = list(map(int,input().split()))
ball = balls[0]
for i in balls:
    ball = gcd(ball,i)

if final_int % ball==0 and final_int <= max(balls):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - Getting Difference
https://atcoder.jp/contests/agc018/tasks/agc018_a

"""
import sys


from fractions import gcd
from functools import reduce

def solve(N, K, A):
    limit = max(A)
    t = reduce(lambda x, y: gcd(x, y), A)
    if K <= limit and K % t == 0:
        return 'POSSIBLE'
    return 'IMPOSSIBLE'


def main(args):
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    ans = solve(N, K, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
from fractions import gcd
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a_max = max(a)

agcd = a[0]
for item in a[1:]:
    agcd = gcd(agcd, item)

if k > a_max:
    print("IMPOSSIBLE")
elif agcd == 1:
    print("POSSIBLE")
elif k % agcd != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
l = list(map(int, input().split()))
s = "POSSIBLE"
m = max(l)
a = l.pop()
for _ in range(n-1):
  b = l.pop()
  while b:
    a,b = b,a%b
if k>m or k%a:
  s = "IM" + s
print(s)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

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


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


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

Submission status: Accepted

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 k<=max(a) else 1
ans=['POSSIBLE','IMPOSSIBLE']
print(ans[j])

Submission status: Accepted

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
g = 0
for i in A:
  g = gcd(g, i)
ans = "IMPOSSIBLE"
for i in A:
  if i >= K and (K - i) % g == 0:
    ans = "POSSIBLE"
    break
print(ans)

Submission status: Accepted

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

def gcd(n,m):
    while n:
        a = n
        n = m % n
        m = a
    return m

def main():
    if K > max(A):
        return 0
    i = A[0]
    for a in A:
        i = gcd(i,a)
    return not(K%i)

print(['IMPOSSIBLE','POSSIBLE'][main()])

Submission status: Accepted

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

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

a_gcd = A[0]
a_max = A[0]
for i in range(1,N,1):
    a_gcd = gcd(a_gcd,A[i])
    if (a_max < A[i]):
        a_max = A[i]

if ((a_max < K) or (0 < (K % a_gcd))):
    print("IMPOSSIBLE")
    exit()

print("POSSIBLE")

Submission status: Accepted

Solution code:
def gcd(a,b):
	if a%b==0:
		return b
	else:
		return gcd(b,a%b)
a,b=list(map(int,input().strip().split()))
n=list(map(int,input().strip().split()))
hi=G=n[0]
for i in range(1,a,1):
	G=gcd(G,n[i])
	if hi<n[i]:
		hi=n[i]
if b%G==0 and b<=hi:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Accepted

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


n,k = map(int,input().split())
l = list(map(int,input().split()))
d = l[0]
for i in l:
    d = gcd(d,i)

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

Submission status: Accepted

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 k%b==0 and k<=max(a):
    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):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


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


for i in range(N):
    if A[i] == K:
        print('POSSIBLE')
        exit()
    elif A[i] > K and (A[i] - K) % g == 0:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Submission status: Accepted

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

from functools import reduce
from fractions import gcd

if K <= max(A) and K % reduce(gcd, A) == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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

g = reduce(gcd, A)
for a in A:
    if gcd(a, K) == g:
        print("POSSIBLE")
        quit()

print("IMPOSSIBLE")

Submission status: Accepted

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

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [0] * (n+1)
for i in range(n):
    b[i+1] = gcd(b[i], a[i])
if (k <= max(a)) & (k >= min(a)):
    if k % b[-1] == 0:
        ans = "POSSIBLE"
    else:
        ans = "IMPOSSIBLE"
else:
    ans = "IMPOSSIBLE"
print(ans)

Submission status: Accepted

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 and k <= max(a) else "IMPOSSIBLE")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n,k=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  if k==arr[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  g=gcd(arr[0],arr[1])
  flag=False
  for i in range(n):
    g=gcd(g,arr[i])
  arr=sorted(arr,reverse=True)
  for i in range(n):
    if k>arr[i]:
      break
    if (arr[i]-k)%g==0:
      flag=True
  if flag:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Accepted

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 and K<=max(A):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
inf = 10**10
import sys
input = sys.stdin.readline
from functools import reduce
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def gcd_list(numbers):
    return reduce(gcd,numbers)
def lcm(a,b):
  return a*b //gcd(a,b)
n,k = map(int,input().split())
a = list(map(int,input().split()))
d = gcd_list(a)
if k > max(a):
    print("IMPOSSIBLE")
else:
    if (max(a)-k)%d == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from functools import reduce
def gcd(a,b):
  if a<b:a,b=b,a
  if a%b==0:return b
  return gcd(b,a%b)
 
read=lambda :map(int,input().split())
n,k=read()
*a,=read()
 
m=max(a)
o=reduce(gcd,a)
print("POSSIBLE" if k<=m and k%o==0 else "IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd

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

max_num = max(As)
prev = As[0]
for i in range(1, len(As)):
    prev = gcd(prev, As[i])

if K % prev == 0 and K <= max_num:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

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

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

if n == 1:
  if k == alist[0]:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
else:
  r = gcd(alist[1], alist[0])
  for _a in alist[2:]:
    r = gcd(_a, r)
  if k <= alist[-1] and k % r == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
from functools import reduce
N,K = map(int,input().split())
A = list(map(int,input().split()))
M = max(A)
def gcd(a, b): 
    while b:
        a, b = b, a % b
    return a
m = reduce(gcd,A)
if K <= M and K % m == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
if max(A)<K:
    print('IMPOSSIBLE')
    sys.exit()
if max(A)==K:
    print('POSSIBLE')
    sys.exit()
if N==1:
    print('IMPOSSIBLE')
    sys.exit()
A=sorted(A,reverse=True)
B=A[1:]
b=B[0]
for i in range(1,len(B)):
    b=gcd(b,B[i])
if (max(A)-K)%b==0:
    print('POSSIBLE')
    sys.exit()
print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import fractions as fr
from functools import reduce
def gcd(a):
  return reduce(fr.gcd, a)
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = gcd(a)
print("POSSIBLE" if (k in a) or (max(a) >= k and (g == 1 or k%g == 0)) else "IMPOSSIBLE")

Submission status: Accepted

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

def gcd(a,b):
    if a%b==0:
        return(b)
    else:
        return(gcd(b,a%b))
    
gcd_num = A[0]
for a in A:
    gcd_num = gcd(a,gcd_num)
    
if K%gcd_num==0 and K<=max(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())
a = list(map(int, input().split()))
print('POSSIBLE' if k % reduce(gcd, a) == 0 and max(a) >= k else 'IMPOSSIBLE')

Submission status: Accepted

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('IMPOSSIBLE')
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: Accepted

Solution code:
from functools import reduce


def gcd(a, b):
    if a < b:
        return gcd(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 = reduce(gcd, A)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")

Submission status: Accepted

Solution code:
from functools import reduce


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

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

Solution code:
from functools import reduce
import fractions
# import math


def gcd_lst(lst):
    return reduce(fractions.gcd, lst)
    # return reduce(math.gcd, lst)

    
N, K = map(int, input().split())
lst_A = list(map(int, input().split()))
max_A = max(lst_A)
gcd_A = gcd_lst(lst_A)

ans = "IMPOSSIBLE"
if K%gcd_A==0 and K<=max_A:
    ans = "POSSIBLE"

print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
pos = "POSSIBLE"
imp = "IMPOSSIBLE"

if max(A) < K:
  print(imp)
  exit()

for i in range(1, N):
  a = A[i - 1]
  b = A[i]
  while a != b:
    if a < b:
      b -= (b // a) * a
      if b == 0:
        b = a
    else:
      a -= (a // b) * b
      if a == 0:
        a = b
  A[i - 1] = a
  A[i] = b

if K % A[-1] == 0:
  print(pos)
else:
  print(imp)

Submission status: Accepted

Solution code:
import fractions
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) >= K:
    for i, a in enumerate(A):
        if i == 0:
            gcd = a
            continue
        gcd = fractions.gcd(gcd, a)
    if K % gcd == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Accepted

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


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

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def gcd(a,b):
  if a%b != 0:
    return gcd(b,a%b)
  else:
    return b
cur = A[0]
for i in range(N):
  cur = gcd(A[i],cur)
if max(A) < K:
  print('IMPOSSIBLE')
else:
  if K%cur != 0:
    print('IMPOSSIBLE')
  else:
    print('POSSIBLE')

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
N,K=map(int,input().split())
A=sorted(map(int,input().split()))
M=reduce(gcd,A)
if K<=A[-1] and K%M==0:print("POSSIBLE")
else:print("IMPOSSIBLE")

Submission status: Accepted

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

if N == 1:
	x = A[0]
else:
	a = A[0]
	for i in range(N - 1):
		b = A[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	x = a

if K % x == 0 and max(A) >= K:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Accepted

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

Submission status: Accepted

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

from fractions import gcd
g = A[0]
for a in A[1:]:
    g = gcd(g,a)
print('POSSIBLE' if K%g==0 else 'IMPOSSIBLE')

Submission status: Accepted

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

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

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

if k > max(a):
    print("IMPOSSIBLE")
    exit()

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

Submission status: Accepted

Solution code:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


N, K = map(int, input().split())
A = list(map(int, input().split()))
G = A[0]
for a in A:
    G = gcd(a, G)
print('POSSIBLE' if K % G == 0 and K <= max(A) else 'IMPOSSIBLE')

Submission status: Accepted

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

Solution code:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
  
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 = gcd_list(a)
    #print(gcd)
    if gcd == 1 or k%gcd == 0 :ans ='POSSIBLE'
    return ans
       
  
  
  return ans
if __name__ == '__main__':
  print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if K in A:
    print("POSSIBLE")
    exit(0)
if K > max(A) or N == 1:
    print("IMPOSSIBLE")
    exit(0)

g = 1000000000
for k in range(1,N):
    g = min(g,gcd(A[k-1],A[k]))

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

Submission status: Accepted

Solution code:
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());print("IM"*(0!=k%F.reduce(f.gcd,a)or max(a)<k)+"POSSIBLE")

Submission status: Accepted

Solution code:
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());
P="POSSIBLE"

if max(a)<k:
    print("IM"+P)
elif k%F.reduce(f.gcd,a)!=0:
    print("IM"+P)
else:
    print(P)

Submission status: Accepted

Solution code:
import functools as F,fractions as f;n,k,*a=map(int,open(0).read().split());
P="POSSIBLE"

if max(a)<k:
    print("IM"+P)
else:
    if k%F.reduce(f.gcd,a)!=0:
        print("IM"+P)
    else:
        print(P)

Submission status: Accepted

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

Submission status: Accepted

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

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

flag = False
for i in range(N):
    if L[i] >= K:
        flag = True
        
if flag:
    g = L[0]
    for i in range(N):
        g = gcd(g, L[i])
        
    if gcd(g, K) == g:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    
else:
    print('IMPOSSIBLE')

Submission status: Accepted

Solution code:
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

N,K = IL()

if N == 1:
    if K == I():
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    l = IL()
    l.sort(reverse=True)

    if K <= l[0]:
        num = gcd(l[0],l[1])
        for i in l:
            if i%num == 0:
                continue
            else:
                num = gcd(num,i)
        if K%num == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

GCD = reduce(gcd, a)

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k>max(a):
    print("IMPOSSIBLE")
    exit()
if k%reduce(gcd,a)==0:
    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
if k in a:
    print("POSSIBLE")
elif k>max(a):
    print("IMPOSSIBLE")
else:
    x=a[0]
    for i in range(1,n):
        x=gcd(x,a[i])
    if k%x==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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


N,K = map(int,input().split())
A = list(map(int,input().split()))
gcd = gcd_list(A)
if K % gcd == 0 and K <= max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Accepted

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

gcd_aa = aa[0]
for a in aa[1:]:
    gcd_aa = gcd(gcd_aa, a)

print('POSSIBLE' if k<=max(aa) and k%gcd_aa==0 else 'IMPOSSIBLE')

Submission status: Accepted

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

max = max(li)

b = min(li)
for a in li:
    while True:
        if a%b == 0:
            break
        tb = b
        b = a%b
        a = tb

if K <= max:
    if K%b == max%b:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Submission status: Accepted

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 = a[0]

    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()