結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー nebukuro09nebukuro09
提出日時 2021-11-05 22:34:43
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 788 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 116,368 KB
実行使用メモリ 30,828 KB
最終ジャッジ日時 2023-09-04 14:48:45
合計ジャッジ時間 11,284 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 954 ms
24,328 KB
testcase_01 AC 23 ms
15,944 KB
testcase_02 AC 22 ms
17,492 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 22 ms
15,164 KB
testcase_09 AC 22 ms
16,604 KB
testcase_10 WA -
testcase_11 AC 22 ms
16,184 KB
testcase_12 AC 22 ms
15,180 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 341 ms
28,620 KB
testcase_19 AC 821 ms
30,344 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 807 ms
26,224 KB
testcase_23 AC 92 ms
20,536 KB
testcase_24 AC 90 ms
19,624 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
    foreach (k; 0..N) {
        while (idx + 1 < X.length && X[idx+1][1] >= N - k) ++idx;
        X[idx][0].writeln;
    }
}
0