結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 KazunKazun
提出日時 2021-11-05 23:29:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 121,148 KB
最終ジャッジ日時 2024-04-25 17:35:29
合計ジャッジ時間 4,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
121,148 KB
testcase_01 AC 36 ms
53,960 KB
testcase_02 AC 89 ms
82,632 KB
testcase_03 AC 85 ms
81,924 KB
testcase_04 AC 82 ms
81,360 KB
testcase_05 AC 85 ms
82,488 KB
testcase_06 AC 88 ms
83,036 KB
testcase_07 AC 89 ms
81,656 KB
testcase_08 AC 35 ms
53,624 KB
testcase_09 AC 76 ms
75,948 KB
testcase_10 AC 77 ms
76,860 KB
testcase_11 AC 37 ms
52,068 KB
testcase_12 AC 38 ms
52,588 KB
testcase_13 AC 147 ms
121,140 KB
testcase_14 AC 138 ms
121,112 KB
testcase_15 AC 137 ms
121,128 KB
testcase_16 AC 142 ms
121,092 KB
testcase_17 AC 143 ms
120,936 KB
testcase_18 AC 104 ms
108,440 KB
testcase_19 AC 138 ms
121,032 KB
testcase_20 AC 124 ms
115,568 KB
testcase_21 AC 126 ms
115,796 KB
testcase_22 AC 134 ms
116,784 KB
testcase_23 AC 89 ms
106,700 KB
testcase_24 AC 136 ms
119,524 KB
testcase_25 AC 136 ms
120,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Multiple_Zeta_Transform(A):
    """ A の倍数を走るにおける Zeta 変換を行う.

    ※ A[0] の値は無視される.
    """

    N=len(A)-1
    S=[1]*(N+1)

    for p in range(2,N+1):
        if S[p]:
            for k in range(N//p,0,-1):
                S[k*p]=0
                A[k]+=A[k*p]
#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

N=int(input())
A=list(map(int,input().split()))

alpha=max(A)
T=[0]*(alpha+1)

for a in A:
    T[a]+=1

Multiple_Zeta_Transform(T)

X=[0]*(N+1)
for a in range(alpha+1):
    X[T[a]]=a

for i in range(N-1,0,-1):
    X[i]=max(X[i],X[i+1])

write("\n".join(map(str,X[:0:-1])))
0