結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー kyo1kyo1
提出日時 2021-12-07 06:57:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 835 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 197,764 KB
実行使用メモリ 8,840 KB
最終ジャッジ日時 2024-04-25 17:55:21
合計ジャッジ時間 9,631 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 835 ms
8,624 KB
testcase_01 AC 4 ms
7,280 KB
testcase_02 AC 4 ms
7,132 KB
testcase_03 AC 5 ms
6,988 KB
testcase_04 AC 4 ms
7,136 KB
testcase_05 AC 4 ms
7,108 KB
testcase_06 AC 4 ms
7,220 KB
testcase_07 AC 5 ms
7,128 KB
testcase_08 AC 4 ms
7,132 KB
testcase_09 AC 4 ms
7,100 KB
testcase_10 AC 4 ms
7,276 KB
testcase_11 AC 4 ms
7,188 KB
testcase_12 AC 4 ms
7,208 KB
testcase_13 AC 484 ms
8,792 KB
testcase_14 AC 491 ms
8,628 KB
testcase_15 AC 493 ms
8,736 KB
testcase_16 AC 494 ms
8,672 KB
testcase_17 AC 487 ms
8,744 KB
testcase_18 AC 244 ms
8,736 KB
testcase_19 AC 664 ms
8,812 KB
testcase_20 AC 115 ms
8,740 KB
testcase_21 AC 115 ms
8,680 KB
testcase_22 AC 677 ms
8,792 KB
testcase_23 AC 25 ms
8,840 KB
testcase_24 AC 26 ms
8,784 KB
testcase_25 AC 446 ms
8,816 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