Submission #3765089
Source Code Expand
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define dump(x) cerr << #x << " = " << (x) << endl;
using namespace std;
typedef pair<int,int> P;
struct edge { int to, cost; };
const int INF = 1e18;
const int MOD = 1e9+7;
template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
s << "[";
for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
s << "]";
return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
s << "(" << p.first << "," << p.second << ")";
return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
s << "{";
for (auto i = m.begin(); i != m.end(); ++i) {
s << i->first << ":" << i->second;
if (next(i) != m.end()) s << ", ";
}
s << "}";
return s;
}
int gcd(int x, int y) {
if(x < y) swap(x, y);
if(x % y == 0) {
return y;
} else {
return gcd(y, x % y);
}
}
signed main()
{
int N, K; cin >> N >> K;
vec<int> A(N);
rep(i, 0, N) {
cin >> A[i];
}
SORT(A);
if (A[N-1] < K) {
cout << "IMPOSSIBLE" << endl;
return 0;
}
int g = A[0];
rep(i, 1, N) {
g = gcd(g, A[i]);
}
if (g != 1 && K % g != 0) {
cout << "IMPOSSIBLE" << endl;
} else {
cout << "POSSIBLE" << endl;
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Getting Difference |
User |
habara_k |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
2282 Byte |
Status |
AC |
Exec Time |
48 ms |
Memory |
1024 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
48 ms |
1024 KB |
subtask_1_04.txt |
AC |
42 ms |
1024 KB |
subtask_1_05.txt |
AC |
22 ms |
640 KB |
subtask_1_06.txt |
AC |
8 ms |
384 KB |
subtask_1_07.txt |
AC |
31 ms |
768 KB |
subtask_1_08.txt |
AC |
40 ms |
896 KB |
subtask_1_09.txt |
AC |
20 ms |
512 KB |
subtask_1_10.txt |
AC |
34 ms |
768 KB |
subtask_1_11.txt |
AC |
37 ms |
896 KB |