結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー kyo1kyo1
提出日時 2021-12-07 06:57:37
言語 C++17
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 861 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 1,937 ms
コンパイル使用メモリ 201,256 KB
実行使用メモリ 8,592 KB
最終ジャッジ日時 2023-08-07 23:44:23
合計ジャッジ時間 10,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 861 ms
8,516 KB
testcase_01 AC 5 ms
6,932 KB
testcase_02 AC 5 ms
6,932 KB
testcase_03 AC 5 ms
6,864 KB
testcase_04 AC 5 ms
6,932 KB
testcase_05 AC 5 ms
6,864 KB
testcase_06 AC 5 ms
6,992 KB
testcase_07 AC 5 ms
6,988 KB
testcase_08 AC 5 ms
7,148 KB
testcase_09 AC 5 ms
6,888 KB
testcase_10 AC 6 ms
6,880 KB
testcase_11 AC 5 ms
6,884 KB
testcase_12 AC 5 ms
6,952 KB
testcase_13 AC 526 ms
8,452 KB
testcase_14 AC 524 ms
8,532 KB
testcase_15 AC 523 ms
8,496 KB
testcase_16 AC 523 ms
8,476 KB
testcase_17 AC 525 ms
8,540 KB
testcase_18 AC 259 ms
8,516 KB
testcase_19 AC 706 ms
8,512 KB
testcase_20 AC 121 ms
8,516 KB
testcase_21 AC 121 ms
8,592 KB
testcase_22 AC 723 ms
8,516 KB
testcase_23 AC 28 ms
8,516 KB
testcase_24 AC 27 ms
8,468 KB
testcase_25 AC 462 ms
8,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(1000000 + 10, 0);
  for (auto&& e : A) {
    cin >> e;
    for (int i = 1; i * i < e + 1; i++) {
      if (e % i == 0) {
        B[i]++;
        if (i * i != e) B[e / i]++;
      }
    }
  }
  vector<int> res(N, 1);
  for (int i = 0; i < (int)B.size(); i++) {
    if (B[i] > 0) {
      res[N - B[i]] = max(res[N - B[i]], i);
    }
  }
  for (int i = 0; i + 1 < N; i++) {
    res[i + 1] = max(res[i + 1], res[i]);
  }
  for (const auto& e : res) {
    cout << e << '\n';
  }
  return 0;
}
0