結果
問題 |
No.1730 GCD on Blackboard in yukicoder
|
ユーザー |
|
提出日時 | 2022-01-29 13:51:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 695 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,384 KB |
実行使用メモリ | 229,228 KB |
最終ジャッジ日時 | 2025-01-01 23:55:56 |
合計ジャッジ時間 | 34,287 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 8 TLE * 9 |
ソースコード
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divisors[::-1] cnt = defaultdict(int) for a in A: divs_a = make_divisors(a) for d in divs_a: cnt[d] += 1 ans = [0] * N for g, c in sorted(cnt.items(), key=lambda x: -x[1]): ans[N - c] = max(ans[N - c], g) for i in range(1, N): if ans[i] == 0: ans[i] = ans[i - 1] print(*ans, sep="\n")