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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

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

g = B[0]
for b in B[1:]:
    g = math.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
// #include <bits/stdc++.h>
#include <iostream>  // cin, cout, string
#include <algorithm> // sort, min/max, upper/lower_bound, transform, count/copy_if
#include <vector>
#include <utility> // pair, swap
#include <functional>
#include <iomanip> // setprecision
#include <map>
#include <set> // multiset
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <stack>
#include <queue> // priority_queue
#include <deque>
#include <bitset>
#include <array>
#include <list>
#include <forward_list>
#include <complex>
#include <ratio>
#include <cassert>
#include <numeric> // accumulate, itoa
#include <random>  // mt19937
#include <iterator>
#include <chrono>
#include <cstring>

using namespace std;

// #define int long long

using i64 = int64_t;
using ll = long long;
using ld = long double;

template <typename T>
using vec = vector<T>;
template <typename T>
using mat = vec<vec<T>>;
template <typename T>
using dic = unordered_map<string, T>;
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>; // dijkstra
// template<typename T, typename U> using P = pair<T, U>;
// template<typename... Args> using func = function<Args...>;
// template<typename T> using pq = priority_queue<T>;

using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pip = pair<int, pii>;
using ppp = pair<pii, pii>;

using vi = vec<int>;
using mi = mat<int>; // Graph
using vp = vec<pii>;

constexpr int IINF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
// constexpr int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
constexpr long long MOD = 1e9 + 7;

#define _overload(_1, _2, _3, name, ...) name
#define _rep1(i, a, b) for (int i = (a), _##i = (b); i < _##i; ++i)
#define _rep2(i, n) _rep1(i, 0, n)
#define _rep3(n) _rep2(i, n)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2, _rep3)(__VA_ARGS__)
#define _rrep1(i, a, b) for (int i = (b)-1, _##i = (a); i >= _##i; --i)
#define _rrep2(i, n) _rrep1(i, 0, n)
#define _rrep3(n) _rrep2(i, n)
#define rrep(...) _overload(__VA_ARGS__, _rrep1, _rrep2, _rrep3)(__VA_ARGS__)

#define each(i, a) for (auto &&i : a)
#define each2(i, a) for (const auto &i : a)

#define pb push_back
// emplace_back(*) == push_back(constructor(*))
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front

#define np next_permutation
#define pp prev_permutation

// make_pair(A, B) == pair<T, U>(A, B)
#define mp make_pair
// mt(...) == tie(...)
#define mt make_tuple

#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))
#define rs(a, l) (a).resize(l)

#define upper(s) transform(all(s), (s).begin(), topper)
#define lower(s) transform(all(s), (s).begin(), tolower)

#define sum(a) accumulate(all(a), 0)
#define elif else if
#define unless(a) if (!(a))
#define qt(a) #a

#define endl '\n'
#define dec(n) fixed << setprecision(n)
#define zfl(n) setfill(‘0’) << setw(n)

template <typename T = int, T l = 0, T r = (T)MOD>
auto rnd = bind(uniform_int_distribution<T>(l, r), mt19937(chrono::steady_clock::now().time_since_epoch().count()));

template <typename T>
inline constexpr T gcd(T a, T b)
{
    if (a == 0 || b == 0)
        return 0;
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <typename T>
inline constexpr T extgcd2(T a, T b, T &x, T &y)
{
    x = 1;
    y = 0;
    while (b)
    {
        T t = a / b;
        a -= t * b;
        swap(a, b);
        x -= t * y;
        swap(x, y);
    }
    return a;
}
template <typename T>
inline constexpr T lcm(T a, T b) { return a / gcd(a, b) * b; }

template <typename T>
inline constexpr bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline constexpr bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &p)
{
    is >> p.first;
    is >> p.second;
    return is;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << p.first << " " << p.second;
    return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &&x : v)
        is >> x;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < (int)v.size(); ++i)
        cout << v[i] << (i + 1 != (int)v.size() ? " " : "");
    return os;
}

#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg>
void __f(const char *name, const Arg &arg)
{
    cerr << name << " : " << arg << endl;
}
template <typename Arg, typename... Args>
void __f(const char *names, const Arg &arg, const Args &... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg << " | ";
    __f(comma + 1, args...);
}

inline auto yes(const bool &c) { return c ? "yes" : "no"; }
inline auto Yes(const bool &c) { return c ? "Yes" : "No"; }
inline auto YES(const bool &c) { return c ? "YES" : "NO"; }
inline auto Possible(const bool &c) { return c ? "Possible" : "Impossible"; }
inline auto POSSIBLE(const bool &c) { return c ? "POSSIBLE" : "IMPOSSIBLE"; }

constexpr int lim = 100007; // 10^5+7

int k, n;
vec<ll> a;
signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    a.resize(n);
    rep(n) cin >> a.at(i);
    ll g = a.at(0);
    rep(n) g = gcd(g, a.at(i));
    ll m = *max_element(all(a));

    cout << POSSIBLE(k % g == 0 && k < m) << endl;
    ;

    return 0;
}

Submission status: Runtime Error

Solution code:
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = As[1] - As[0]
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2000000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N,K,*A = map(int,open(0).read().split())
g = reduce(math.gcd,A)
print("POSSIBLE" if K % g == 0 else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import functools
import math

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(math.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

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


n, k = map(int, input().split())
a = list(map(int, input().split())
        
m = max(a)
         
g = a[0]
         
for i in range(n):
    g = gcd(g, a[i])

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

Submission status: Runtime Error

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 i in range(n):
    g = gcd(g, a[i])

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

Submission status: Runtime Error

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

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

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

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
	g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
  g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(200000)

N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
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: Runtime Error

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
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: Runtime Error

Solution code:
import sys
from functools import reduce
from math import gcd

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

# max(a) < k → だめ
# N == 1 ぴったじゃなきゃだめ
# N > 1
## 互いに素な数が含まれている → ○
## 含まれてないが、kがその倍数 → ○
if max(a) < k:
    print(IMPOSSIBLE)
    exit()
if n == 1:
    if k == a[0]:
        print(POSSIBLE)
    else:
        print(IMPOSSIBLE)
else:
    g = reduce(lambda a, b: gcd(a, b), a)
    if g == 1:
        print(POSSIBLE)
    else:
        if k % g == 0:
            print(POSSIBLE)
        else:
            print(IMPOSSIBLE)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print("IMPOSSIBLE")
else:
    temp = A[0]
    for a in A[1:]:
        temp = gcd(a, temp)
    if K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

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

# いずれか2つの数字のGCDが1 必ずTrue
# いずれか2つの数字のGCDが2 かつ Ai - K % 2 == 0 のものが存在する場合 True
# いずれか2つのGCDが計算できれば、答えが導けるが、いずれか2つの組み合わせはA * (A-1) // 2通りあるから間に合わない
# 累積GCDで1になる → どうにかこうにか1にできる
# 累積GCDで2になる → どの組み合わせをとっても2にしかならない


def main():
    ma = max(A)
    if ma < K:
        return False
    if K in A:
        return True
    gcd = A[0]
    for a in A:
        gcd = math.gcd(gcd, a)
    for a in A:
        if (a-K) % gcd == 0:
            return True
    return False
    

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

Submission status: Runtime Error

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


if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
# A - Getting Difference
import math
from functools import reduce

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

gcd = reduce(math.gcd, A) 

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

Submission status: Runtime Error

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 = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])

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

Submission status: Runtime Error

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

A = list(map(int, input().split()))
import math
def list_gcd(X):
    t = max(X)
    for i in X:
        t = math.gcd(t, i)
    return t

if k in A or (k % list_gcd(A) == 0 and max(A) >= k):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
m = max(A)
if K > m:
    print('IMPOSSIBLE')
else:
    gcd = xgcd(A[0],A[1])
    for i in range(2,N):
        gcd = xgcd(gcd,A[i])
        if gcd == 1:
            print('POSSIBLE')
            break
    else:
        if K % gcd == 0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from math import gcd
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
gcm = 10**9+7
for i in range(N-1):
    gcm = min(gcm, gcd(A[i], A[i+1]))
if N == 1:
    print('IMPOSSIBLE')
    exit()

print('POSSIBLE' if K % gcm == 0 and K <= A[0] else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def possible(b):
    print('POSSIBLE' if b else 'IMPOSSIIBLE')

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

if k in A:
    possible(True)
    exit()

if n == 1:
    possible(False)
    exit()
A = set(A)
A = list(A)
n = len(A)
A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from fractions import *
g = D[0]
for d in D:
    g = gcd(g, d)

print('POSSIBLE' if k % g == 0 and k <= A[-1] else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def possible(b):
    print('POSSIBLE' if b else 'IMPOSSIIBLE')

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

if k in A:
    possible(True)
    exit()

if n == 1:
    possible(False)
    exit()
A = set(A)
A = list(A)

A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from fractions import *
g = D[0]
for d in D:
    g = gcd(g, d)

print('POSSIBLE' if k % g == 0 and k <= A[-1] else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
def possible(b):
    print('POSSIBLE' if b else 'IMPOSSIIBLE')

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

if k in A:
    possible(True)
    exit()

if n == 1:
    possible(False)
    exit()

A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from fractions import *
g = D[0]
for d in D:
    g = gcd(g, d)

print('POSSIBLE' if k % g == 0 and k <= A[-1] else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
if n == 1:
    print('IMPOSSIBLE')
    exit()
A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from math import *
g = D[0]
for d in D:
    g = gcd(g, d)
print('POSSIBLE'if g == 1 else 'IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/agc018/tasks/agc018_a

n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
# ボールはどんどん増えていく
nums.sort()
if k <= nums[-1]:
    diff = set([])
    for i in range(1, n):
        diff.add(abs(nums[i] - nums[i - 1]))

    diff = list(diff)
    dp = [False] * (k + 1)
    dp[0] = True
    for num in nums:
        if num <= k:
            dp[num] = True
    for i in range(len(diff)):
        num = nums[i]
        for j in range(k + 1):
            if j - num >= 0:
                dp[j] = dp[j - num] or dp[j]

    if dp[k]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
A_list.sort()
sub_A_list = A_list.copy()[1:]

if K in A_list:
    print('POSSIBLE')

else:
    for i in range(N-1):
        sub_A_list[i] -= A_list[i]
        print(sub_A_list)
    
    a = []   
    for i in range(N-2):
        if sub_A_list[i] == sub_A_list[i+1]:
            a.append(-1)

    if len(a) == N-2:
        print('IMPOSSIBLE')
    
    else:
        print('POSSIBLE')

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
if k>max(a):
    print("IMPOSSIBLE")
    exit()
g=a[0]
for i in range(1,n):
    g=math.gcd(g,a[i])
for i in range(n):
    a[i]=a[i]%g
if k%g in a:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[0]*n
if k>max(a):
    print("IMPOSSIBLE")
    exit()
g=a[0]
for i in range(1,n):
    g=math.gcd(g,a[i])
for i in range(n):
    b[i]=a[i]%g
if k%g in b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import math

N,K,*A = map(int,open(0).read().split())
g = A[0]
for i in A:
   g = math.gcd(g,i)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import scipy
import itertools
import fractions
import functools

def gcd(nums):
    return functools.reduce(euclid, nums)

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    g = gcd(a)
    if k <= max(a) and k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
from functools import reduce, gcd

def main():
  n, k = map(int, input().split())
  la = list(map(int, input().split()))
  if max(la) > k and (max(la) - k) % (reduce(gcd, la)) == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  
if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import gcd
from functools import reduce

def main():
  n, k = map(int, input().split())
  la = list(map(int, input().split()))
  if max(la) > k and (max(la) - k) % (reduce(gcd, la)) == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  
if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
import math

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

A.sort()
A.reverse()

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
N,K=map(int,input().split())
L=list(map(int,input().split()))
tmp=0
for i in range(1,N):
	if i==1:
		tmp=fractions.gcd(L[0],L[1])
	else:
		tmp=fractions.gcd(tmp,L[i])
if max(L)>=K and K%tmp==0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
N,K=map(int,input().split())
L=list(map(int,input().split()))
tmp=0
if max(L)<K:
	print("IMPOSSIBLE")
	exit()
for i in range(1,N):
	if i==1:
		if L[0]==K or L[i]==K:
			print("POSSIBLE")
			exit()
		tmp=fractions.gcd(L[0],L[1])
		if tmp<=K and K%tmp==0:
			print("POSSIBLE")
			exit()
	else:
		ifL[i]==K:
			print("POSSIBLE")
			exit()
		tmp=fractions.gcd(tmp,L[i])
		if tmp<=K and K%tmp==0:
			print("POSSIBLE")
			exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

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

MAX = max(A)
GCD = gcd(A[0], A[1])
for i in range(2, n):
	GCD = gcd(GCD, A[i])

if k % GCD == 0 and k <= MAX:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from fractions import gcd
# from math import gcd

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

M = max(A)

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

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
from math import gcd

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

M = max(A)

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

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

Submission status: Runtime Error

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 or N == 1:
    print("IMPOSSIBLE")
    exit()

A.sort()
for i in range(1, N):
    tmp = abs(A[i - 1] - A[i])
    if K % tmp == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

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

A.sort()
for i in range(1, N):
    tmp = abs(A[i - 1] - A[i])
    if K % tmp == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    from functools import reduce
    from math import gcd
    G=reduce(gcd,A)

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

resolve()

Submission status: Runtime Error

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    maxA = A.pop()
    if maxA < K or (N == 1 and maxA != K):
        return print("IMPOSSIBLE")
    g = A[0]

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

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

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    maxA = A.pop()
    if maxA < K:
        return print(0)
    g = A[0]

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

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

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

if N == 1:
    if A[0] == K:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    exit()

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

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

min_diff = min([A[i] - A[i-1] for i in range(1,N)])

for i in range(N):
    if abs(A[i]-K) % min_diff == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Submission status: Runtime Error

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

g = fractions.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = fractions.gcd(g,ai[i+1])

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

Submission status: Runtime Error

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

g = math.gcd(ai[0],ai[1])

for i in range(1,n-1):
    #print(i)
    g = math.gcd(g,ai[i+1])

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    ma=max(A)

    from functools import reduce
    from math import gcd

    g=reduce(gcd,A)
    if K%g==0 and K<=ma:
        print('POSSIBLE')
    else: print('IMPOSSIBLE')

resolve()

Submission status: Runtime Error

Solution code:
from math import gcd
def check():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K > max(A):
        return False
    g = A[0]
    for i in range(1,N):
        g = gcd(g,A[i])
    if K%g != 0:
        return False
    return True
if check():
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

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

Submission status: Runtime Error

Solution code:
INF = 10 ** 20
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left
from functools import reduce
from math import gcd

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

    if k > max(a):
        print('IMPOSSIBLE')
        return

    G = reduce(gcd,a)
    if k%G == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBEL')
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
print('POSSIBLE' if (K <= A[-1] and K % gcd_all() == 0) else 'IMPOSSIBLE')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
N,K=map(int,input().split())
a=list(map(int,input().split()))
bef=a[0]
gcd=a[0]
max_=a[0]
for i in range(1,N):
    if max_<a[i]:
        max_=a[i]
    gcd=math.gcd(gcd,a[i])
if max_<K:
    print("IMPOSSIBLE")
else:
    if K%gcd==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Submission status: Runtime Error

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

a_gcd = a[0]
for i in range(1, n):
    a_gcd = gcd(a_gcd, a[i])
ans = True
if k > max(a):
    ans = False
if k % a_gcd != 0:
    ans = False
if k in a:
    ans = True

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

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/agc018/tasks/agc018_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


from math import gcd
N, K = read_ints()
A = read_ints()
# 結論からいうとKがminとmaxの間でかつ、gcd(A)の倍数であるならば、必ずKを構成することができる。
# ∵ある2要素a,bからはgcd(a,b)の倍数しか作ることができない。これをすべての要素に適応するだけ。

g = 0  # gcdの単位元
for a in A:
    g = gcd(g, a)

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