結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー nebukuro09nebukuro09
提出日時 2021-11-05 21:38:56
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 3,125 ms
コンパイル使用メモリ 118,544 KB
実行使用メモリ 34,528 KB
最終ジャッジ日時 2023-09-04 14:47:36
合計ジャッジ時間 13,562 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 943 ms
25,608 KB
testcase_01 AC 22 ms
17,140 KB
testcase_02 AC 22 ms
14,840 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 22 ms
15,128 KB
testcase_09 AC 22 ms
15,420 KB
testcase_10 WA -
testcase_11 AC 22 ms
16,676 KB
testcase_12 AC 23 ms
16,932 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 344 ms
29,660 KB
testcase_19 AC 832 ms
34,528 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 837 ms
26,448 KB
testcase_23 AC 90 ms
19,716 KB
testcase_24 AC 92 ms
20,456 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]).array;

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