提出 #8540596
ソースコード 拡げる
#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;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Getting Difference |
| ユーザ | koyamaso |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 300 |
| コード長 | 1486 Byte |
| 結果 | AC |
| 実行時間 | 41 ms |
| メモリ | 640 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 256 KiB |
| sample_02.txt | AC | 1 ms | 256 KiB |
| sample_03.txt | AC | 1 ms | 256 KiB |
| sample_04.txt | AC | 1 ms | 256 KiB |
| subtask_1_01.txt | AC | 1 ms | 256 KiB |
| subtask_1_02.txt | AC | 1 ms | 256 KiB |
| subtask_1_03.txt | AC | 41 ms | 640 KiB |
| subtask_1_04.txt | AC | 41 ms | 640 KiB |
| subtask_1_05.txt | AC | 22 ms | 512 KiB |
| subtask_1_06.txt | AC | 7 ms | 256 KiB |
| subtask_1_07.txt | AC | 25 ms | 512 KiB |
| subtask_1_08.txt | AC | 36 ms | 640 KiB |
| subtask_1_09.txt | AC | 17 ms | 384 KiB |
| subtask_1_10.txt | AC | 29 ms | 512 KiB |
| subtask_1_11.txt | AC | 33 ms | 512 KiB |