結果

問題 No.2211 Frequency Table of GCD
ユーザー dachengzdachengz
提出日時 2023-02-11 13:17:58
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,107 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 103,684 KB
最終ジャッジ日時 2023-09-22 11:11:37
合計ジャッジ時間 9,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 74 ms
71,844 KB
testcase_02 AC 72 ms
71,536 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 129 ms
85,444 KB
testcase_09 AC 128 ms
82,912 KB
testcase_10 AC 174 ms
95,200 KB
testcase_11 AC 159 ms
90,056 KB
testcase_12 AC 186 ms
97,272 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 397 ms
103,500 KB
testcase_19 AC 399 ms
103,420 KB
testcase_20 AC 392 ms
103,508 KB
testcase_21 AC 375 ms
103,560 KB
testcase_22 AC 402 ms
103,176 KB
testcase_23 RE -
testcase_24 AC 370 ms
103,684 KB
testcase_25 AC 110 ms
99,476 KB
testcase_26 AC 70 ms
71,264 KB
testcase_27 AC 350 ms
103,284 KB
testcase_28 AC 387 ms
103,580 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(N)
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