結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー qibqib
提出日時 2023-02-03 22:20:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 424 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 123,560 KB
最終ジャッジ日時 2023-09-15 18:23:31
合計ジャッジ時間 8,091 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 186 ms
92,484 KB
testcase_02 AC 185 ms
92,732 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 185 ms
92,536 KB
testcase_12 AC 183 ms
92,396 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
a = list(map(int, input().split()))

m = 10 ** 6
cnt = [0 for _ in range(m + 1)]
for x in a:
  cnt[x] += 1

dp = [0 for _ in range(m + 1)]
dp[1] = n
for x in range(2, m + 1):
  for y in range(x, m + 1, x):
    dp[x] += cnt[y]
  
ans = [0 for _ in range(n)]
for x in range(m, 0, -1):
  if dp[x] == 0:
    continue
  ans[n - dp[x]] = max(ans[n - dp[x]], x)

ans[-1] = max(a)
print(*ans, sep="\n")
0