結果

問題 No.2211 Frequency Table of GCD
ユーザー tamatotamato
提出日時 2023-02-10 21:51:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,555 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 142,884 KB
最終ジャッジ日時 2023-09-22 01:05:07
合計ジャッジ時間 15,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,512 KB
testcase_01 AC 98 ms
71,636 KB
testcase_02 AC 97 ms
71,700 KB
testcase_03 AC 186 ms
82,060 KB
testcase_04 AC 501 ms
102,788 KB
testcase_05 AC 693 ms
117,304 KB
testcase_06 AC 491 ms
97,692 KB
testcase_07 AC 727 ms
114,908 KB
testcase_08 AC 116 ms
86,360 KB
testcase_09 AC 115 ms
82,176 KB
testcase_10 AC 134 ms
98,764 KB
testcase_11 AC 126 ms
91,636 KB
testcase_12 AC 134 ms
101,868 KB
testcase_13 AC 450 ms
98,536 KB
testcase_14 AC 480 ms
95,308 KB
testcase_15 AC 363 ms
88,376 KB
testcase_16 AC 455 ms
94,112 KB
testcase_17 AC 644 ms
112,764 KB
testcase_18 AC 959 ms
128,792 KB
testcase_19 AC 1,123 ms
128,860 KB
testcase_20 AC 965 ms
128,704 KB
testcase_21 AC 962 ms
128,872 KB
testcase_22 AC 967 ms
129,260 KB
testcase_23 AC 157 ms
81,608 KB
testcase_24 AC 202 ms
110,116 KB
testcase_25 AC 142 ms
105,052 KB
testcase_26 AC 100 ms
71,500 KB
testcase_27 AC 1,555 ms
142,884 KB
testcase_28 AC 201 ms
110,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


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

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

    cnt = [0] * (M+1)
    C = Counter(A)
    for a in C:
        div = []
        for d in range(1, a+1):
            if d * d > a:
                break
            if a % d == 0:
                div.append(d)
                div.append(a // d)
        if div[-1] == div[-2]:
            div.pop()
        for d in div:
            cnt[d] += C[a]

    ans = [0] * (M+1)
    for k in range(M, 0, -1):
        ans[k] = (pow(2, cnt[k], mod) - 1) % mod
        for x in range(2, M+1):
            if k * x > M:
                break
            ans[k] = (ans[k] - ans[k * x]) % mod
    for k in range(1, M+1):
        print(ans[k])


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