結果

問題 No.2211 Frequency Table of GCD
ユーザー lloyzlloyz
提出日時 2023-03-23 00:21:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,167 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,876 KB
実行使用メモリ 107,912 KB
最終ジャッジ日時 2023-10-18 19:11:33
合計ジャッジ時間 6,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,504 KB
testcase_01 AC 37 ms
53,504 KB
testcase_02 AC 36 ms
53,504 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    mod = 998244353

    IsPrime = [True for _ in range(m + 1)]
    IsPrime[0] = IsPrime[1] = False
    Primes = set()
    for i in range(2, m + 1):
        if IsPrime[i]:
            Primes.add(i)
            for j in range(i * i, m + 1, i):
                IsPrime[j] = False
    C = [0 for _ in range(m + 1)]
    for i in range(n):
        C[A[i]] += 1

    ANS = [0 for _ in range(m + 1)]
    for i in range(2, m + 1):
        cnt = 0
        CC = []
        for j in range(i + i, m + 1, i):
            cnt += C[j]
            if j // i in Primes and C[j] > 0:
                CC.append(C[j])
        res = (pow(2, C[i], mod) - 1) * pow(2, cnt, mod) % mod
        k = len(CC)
        for p1 in range(k):
            for p2 in range(p1 + 1, k):
                res += (pow(2, CC[p1], mod) - 1) * (pow(2, CC[p2], mod) - 1) % mod
                res %= mod
        ANS[i] = res
    res = 0
    for i in range(2, m + 1):
        res += ANS[i]
        res %= mod
    ANS[1] = (pow(2, n, mod) - res - 1) % mod
    print(*ANS[1:], sep='\n')

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