結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー |
|
提出日時 | 2021-11-05 21:38:56 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 828 ms |
コンパイル使用メモリ | 130,176 KB |
実行使用メモリ | 34,212 KB |
最終ジャッジ日時 | 2024-06-22 13:06:03 |
合計ジャッジ時間 | 10,819 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 WA * 14 |
ソースコード
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;}}