結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー ぷらぷら
提出日時 2021-11-05 21:23:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,141 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 197,008 KB
実行使用メモリ 8,156 KB
最終ジャッジ日時 2024-04-25 17:13:05
合計ジャッジ時間 14,533 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,141 ms
7,940 KB
testcase_01 AC 5 ms
7,168 KB
testcase_02 AC 4 ms
7,348 KB
testcase_03 AC 5 ms
7,244 KB
testcase_04 AC 5 ms
7,100 KB
testcase_05 AC 5 ms
7,320 KB
testcase_06 AC 5 ms
7,164 KB
testcase_07 AC 5 ms
7,204 KB
testcase_08 AC 5 ms
7,084 KB
testcase_09 AC 5 ms
7,148 KB
testcase_10 AC 5 ms
7,152 KB
testcase_11 AC 4 ms
7,328 KB
testcase_12 AC 4 ms
7,300 KB
testcase_13 AC 814 ms
8,048 KB
testcase_14 AC 819 ms
8,156 KB
testcase_15 AC 812 ms
8,120 KB
testcase_16 AC 816 ms
7,916 KB
testcase_17 AC 808 ms
7,976 KB
testcase_18 AC 545 ms
7,852 KB
testcase_19 AC 996 ms
7,864 KB
testcase_20 AC 398 ms
8,080 KB
testcase_21 AC 397 ms
7,972 KB
testcase_22 AC 1,025 ms
7,920 KB
testcase_23 AC 286 ms
7,940 KB
testcase_24 AC 296 ms
7,932 KB
testcase_25 AC 749 ms
7,936 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