AtCoder Grand Contest 018

Submission #1447032

Source codeソースコード

#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, K, A[100000];

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll judge() {
  ll d = A[0];
  REP(i, 1, N) d = gcd(d, A[i]);
  return d;
}

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) cin >> A[i];

  sort(A, A + N);

  ll d = judge();
  cout << (A[N - 1] >= K && K % d == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Submission

Task問題 A - Getting Difference
User nameユーザ名 Shinya Kato
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 521 Byte
File nameファイル名
Exec time実行時間 48 ms
Memory usageメモリ使用量 1024 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 300 / 300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 43 ms 1024 KB
subtask_1_05.txt AC 23 ms 640 KB
subtask_1_06.txt AC 8 ms 384 KB
subtask_1_07.txt AC 29 ms 768 KB
subtask_1_08.txt AC 42 ms 896 KB
subtask_1_09.txt AC 20 ms 512 KB
subtask_1_10.txt AC 35 ms 768 KB
subtask_1_11.txt AC 39 ms 896 KB