結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー ぷらぷら
提出日時 2021-11-05 21:23:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,228 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 201,116 KB
実行使用メモリ 8,000 KB
最終ジャッジ日時 2023-08-07 22:55:38
合計ジャッジ時間 14,970 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,228 ms
7,856 KB
testcase_01 AC 5 ms
7,100 KB
testcase_02 AC 4 ms
6,984 KB
testcase_03 AC 5 ms
6,952 KB
testcase_04 AC 5 ms
6,992 KB
testcase_05 AC 5 ms
6,924 KB
testcase_06 AC 5 ms
6,992 KB
testcase_07 AC 5 ms
6,992 KB
testcase_08 AC 5 ms
6,908 KB
testcase_09 AC 5 ms
6,876 KB
testcase_10 AC 5 ms
6,900 KB
testcase_11 AC 4 ms
6,908 KB
testcase_12 AC 4 ms
6,880 KB
testcase_13 AC 811 ms
7,904 KB
testcase_14 AC 801 ms
7,728 KB
testcase_15 AC 804 ms
7,660 KB
testcase_16 AC 804 ms
7,716 KB
testcase_17 AC 797 ms
7,724 KB
testcase_18 AC 537 ms
7,696 KB
testcase_19 AC 994 ms
7,744 KB
testcase_20 AC 400 ms
7,856 KB
testcase_21 AC 392 ms
7,772 KB
testcase_22 AC 1,095 ms
7,664 KB
testcase_23 AC 286 ms
7,784 KB
testcase_24 AC 286 ms
7,716 KB
testcase_25 AC 752 ms
8,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>tmp(1000001);
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        for(int j = 1; j*j <= A; j++) {
            if(A%j == 0) {
                tmp[j]++;
                if(j*j != A) {
                    tmp[A/j]++;
                }
            }
        }
    }
    vector<int>ans(N+1);
    for(int i = 1; i <= 1000000; i++) {
        ans[N-tmp[i]] = i;
    }
    for(int i = 0; i < N; i++) {
        ans[i+1] = max(ans[i+1],ans[i]);
    }
    for(int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}
0