結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー nebukuro09nebukuro09
提出日時 2021-11-05 23:24:26
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 856 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 116,192 KB
実行使用メモリ 29,720 KB
最終ジャッジ日時 2023-09-04 14:49:45
合計ジャッジ時間 10,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 856 ms
24,216 KB
testcase_01 AC 22 ms
15,380 KB
testcase_02 AC 22 ms
15,432 KB
testcase_03 AC 23 ms
16,400 KB
testcase_04 AC 24 ms
16,936 KB
testcase_05 AC 22 ms
14,884 KB
testcase_06 AC 22 ms
16,448 KB
testcase_07 AC 23 ms
16,196 KB
testcase_08 AC 22 ms
16,172 KB
testcase_09 AC 22 ms
15,620 KB
testcase_10 AC 23 ms
14,832 KB
testcase_11 AC 22 ms
15,948 KB
testcase_12 AC 22 ms
16,380 KB
testcase_13 AC 638 ms
28,920 KB
testcase_14 AC 637 ms
28,592 KB
testcase_15 AC 636 ms
28,964 KB
testcase_16 AC 636 ms
27,936 KB
testcase_17 AC 636 ms
29,516 KB
testcase_18 AC 319 ms
26,840 KB
testcase_19 AC 751 ms
29,720 KB
testcase_20 AC 191 ms
20,636 KB
testcase_21 AC 191 ms
21,088 KB
testcase_22 AC 728 ms
24,800 KB
testcase_23 AC 92 ms
20,696 KB
testcase_24 AC 91 ms
19,520 KB
testcase_25 AC 518 ms
29,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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