結果
| 問題 |
No.1730 GCD on Blackboard in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-29 14:18:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 683 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 216,048 KB |
| 最終ジャッジ日時 | 2025-01-02 01:03:07 |
| 合計ジャッジ時間 | 34,855 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 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):
ans[i] = max(ans[i], ans[i - 1])
print(*ans, sep="\n")