結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 tamatotamato
提出日時 2021-11-05 22:21:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,767 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 82,944 KB
実行使用メモリ 197,504 KB
最終ジャッジ日時 2024-04-24 06:11:15
合計ジャッジ時間 19,243 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 325 ms
126,768 KB
testcase_01 AC 246 ms
120,312 KB
testcase_02 AC 246 ms
120,704 KB
testcase_03 AC 329 ms
120,576 KB
testcase_04 AC 336 ms
120,320 KB
testcase_05 AC 341 ms
120,576 KB
testcase_06 AC 334 ms
120,832 KB
testcase_07 AC 332 ms
120,448 KB
testcase_08 AC 300 ms
120,576 KB
testcase_09 AC 264 ms
120,576 KB
testcase_10 AC 323 ms
120,704 KB
testcase_11 AC 241 ms
120,320 KB
testcase_12 AC 243 ms
120,448 KB
testcase_13 AC 1,751 ms
184,844 KB
testcase_14 AC 1,626 ms
185,108 KB
testcase_15 AC 1,569 ms
184,956 KB
testcase_16 AC 1,618 ms
185,096 KB
testcase_17 AC 1,767 ms
184,584 KB
testcase_18 AC 1,011 ms
183,488 KB
testcase_19 AC 1,014 ms
197,504 KB
testcase_20 AC 395 ms
127,156 KB
testcase_21 AC 401 ms
127,148 KB
testcase_22 AC 323 ms
126,636 KB
testcase_23 AC 311 ms
127,768 KB
testcase_24 AC 322 ms
127,492 KB
testcase_25 AC 1,071 ms
187,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
NN = 10 ** 6


def main():
    import sys
    from collections import Counter
    input = sys.stdin.readline

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

    div = [[] for _ in range(NN + 1)]
    for i in range(1, NN+1):
        for x in range(1, NN+1):
            if i * x > NN:
                break
            if i * x in C:
                div[i*x].append(i)

    cnt = [N] * (NN+1)
    for a in C:
        k = C[a]
        for d in div[a]:
            cnt[d] -= k

    ans = [1] * (N+1)
    for x in range(1, NN+1):
        k = cnt[x]
        ans[k] = x
    for i in range(1, N+1):
        ans[i] = max(ans[i], ans[i-1])
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()
0