結果

問題 No.1730 GCD on Blackboard in yukicoder
コンテスト
ユーザー nebukuro09
提出日時 2021-11-05 23:24:26
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 961 ms / 2,000 ms
コード長 827 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 518 ms
コンパイル使用メモリ 109,568 KB
実行使用メモリ 29,320 KB
最終ジャッジ日時 2026-03-06 18:43:05
合計ジャッジ時間 9,836 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto cnt = new int[](10^^6+1);

    foreach (a; A) {
        for (int i = 1; i * i <= a; ++i) if (a % i == 0) {
            cnt[i] += 1;
            if (i * i != a) cnt[a/i] += 1;
        }
    }

    auto X = iota(10^^6+1).map!(i => tuple(i, cnt[i])).array;
    X = X.filter!(x => x[1] != 0).array;
    X.sort!((a, b) => a[1] == b[1] ? a[0] < b[0] : a[1] > b[1]);

    int idx = 0;
    int ans = 1;

    foreach (k; 0..N) {
        while (idx + 1 < X.length && X[idx+1][1] >= N - k) ++idx, ans = max(ans, X[idx][0]);
        ans.writeln;
    }
}
0