結果

問題 No.2211 Frequency Table of GCD
ユーザー dachengzdachengz
提出日時 2023-02-11 13:18:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 1,107 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 103,748 KB
最終ジャッジ日時 2023-09-22 11:15:23
合計ジャッジ時間 9,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,516 KB
testcase_01 AC 72 ms
71,652 KB
testcase_02 AC 72 ms
71,396 KB
testcase_03 AC 158 ms
83,920 KB
testcase_04 AC 257 ms
89,876 KB
testcase_05 AC 319 ms
97,640 KB
testcase_06 AC 242 ms
87,508 KB
testcase_07 AC 328 ms
96,100 KB
testcase_08 AC 127 ms
84,612 KB
testcase_09 AC 123 ms
81,684 KB
testcase_10 AC 168 ms
93,624 KB
testcase_11 AC 152 ms
88,720 KB
testcase_12 AC 178 ms
95,868 KB
testcase_13 AC 236 ms
87,748 KB
testcase_14 AC 231 ms
87,088 KB
testcase_15 AC 200 ms
85,688 KB
testcase_16 AC 225 ms
86,552 KB
testcase_17 AC 300 ms
95,288 KB
testcase_18 AC 402 ms
103,416 KB
testcase_19 AC 400 ms
103,516 KB
testcase_20 AC 404 ms
103,604 KB
testcase_21 AC 414 ms
103,748 KB
testcase_22 AC 405 ms
103,024 KB
testcase_23 AC 141 ms
83,912 KB
testcase_24 AC 384 ms
103,392 KB
testcase_25 AC 105 ms
97,336 KB
testcase_26 AC 71 ms
71,464 KB
testcase_27 AC 349 ms
103,296 KB
testcase_28 AC 392 ms
103,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isqrt(n):
    if n <= 0:
        return 0

    x = int((n ** 0.5) * (1 + 1e-14))
    while True:
        y = (x + n // x) // 2
        if y >= x:
            return x
        x = y

def smf_sieve(N):
    v = isqrt(N)
    assert v * v <= N < (v + 1) * (v + 1)
    smf = list(range(N + 1))
    for d in range(2, N + 1, 2):
        smf[d] = 2
    for p in range(3, v + 1, 2):
        if smf[p] != p:
            continue
        for d in range(p * p, N + 1, 2 * p):
            if smf[d] == d:
                smf[d] = p
    return smf

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

mod = 998244353

C = [0] * (M + 1)
smf = smf_sieve(M)
for a in A:
    a0 = a
    divs = [1]
    while a > 1:
        p = smf[a]
        r = [1]
        while smf[a] == p:
            a //= p
            r.append(r[-1] * p)
        divs = [d * q for d in divs for q in r]
    for d in divs:
        C[d] += 1
C = [pow(2, c, mod) - 1 for c in C]
M1 = M + 1
for i in range(M // 2, 0, -1):
    tmp = C[i]
    for n in range(i + i, M1, i):
        tmp -= C[n]
    C[i] = tmp % mod
for c in C[1:]:
    print(c)
0