結果
| 問題 |
No.1730 GCD on Blackboard in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-05 23:24:26 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 933 ms / 2,000 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 129,844 KB |
| 実行使用メモリ | 29,880 KB |
| 最終ジャッジ日時 | 2024-06-22 13:07:50 |
| 合計ジャッジ時間 | 10,038 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
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;
}
}