結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 tamatotamato
提出日時 2021-11-05 22:23:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,522 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 178,044 KB
最終ジャッジ日時 2024-04-24 06:14:12
合計ジャッジ時間 17,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 273 ms
126,376 KB
testcase_01 AC 212 ms
120,192 KB
testcase_02 AC 205 ms
120,320 KB
testcase_03 AC 267 ms
120,576 KB
testcase_04 AC 272 ms
120,832 KB
testcase_05 AC 279 ms
120,448 KB
testcase_06 AC 276 ms
120,448 KB
testcase_07 AC 280 ms
120,704 KB
testcase_08 AC 247 ms
120,448 KB
testcase_09 AC 223 ms
120,704 KB
testcase_10 AC 270 ms
120,704 KB
testcase_11 AC 203 ms
120,320 KB
testcase_12 AC 205 ms
120,448 KB
testcase_13 AC 1,522 ms
168,584 KB
testcase_14 AC 1,480 ms
168,580 KB
testcase_15 AC 1,454 ms
168,316 KB
testcase_16 AC 1,441 ms
169,100 KB
testcase_17 AC 1,413 ms
168,456 KB
testcase_18 AC 1,010 ms
165,696 KB
testcase_19 AC 1,103 ms
178,044 KB
testcase_20 AC 346 ms
127,236 KB
testcase_21 AC 330 ms
127,544 KB
testcase_22 AC 275 ms
126,504 KB
testcase_23 AC 262 ms
127,740 KB
testcase_24 AC 264 ms
127,620 KB
testcase_25 AC 1,069 ms
170,688 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(101, 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
        for d in range(1, 101):
            if a % d == 0:
                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