Submission #8540596


Source Code Expand

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int gcd(int a, int b) {
  if(a<b) swap(a,b);
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  int mi = INF,ma = -INF;
  rep(i,N) {
    cin >> A[i];
    mi = min(mi,A[i]);
    ma = max(ma,A[i]);
  }
  rep(i,N) {
    if(A[i] == K) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  int g = A[0];
  rep(i,N) {
    g = gcd(g,A[i]);
  }
  if(ma < K) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  if(K%g != 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << "POSSIBLE" << endl;
  return 0;
}

Submission Info

Submission Time
Task A - Getting Difference
User koyamaso
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1486 Byte
Status AC
Exec Time 41 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 41 ms 640 KB
subtask_1_04.txt AC 41 ms 640 KB
subtask_1_05.txt AC 22 ms 512 KB
subtask_1_06.txt AC 7 ms 256 KB
subtask_1_07.txt AC 25 ms 512 KB
subtask_1_08.txt AC 36 ms 640 KB
subtask_1_09.txt AC 17 ms 384 KB
subtask_1_10.txt AC 29 ms 512 KB
subtask_1_11.txt AC 33 ms 512 KB