結果

問題 No.2211 Frequency Table of GCD
ユーザー rlangevinrlangevin
提出日時 2023-02-10 22:26:51
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 881 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 141,796 KB
最終ジャッジ日時 2023-09-21 23:40:53
合計ジャッジ時間 15,995 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
77,800 KB
testcase_01 AC 79 ms
77,496 KB
testcase_02 AC 80 ms
77,504 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 98 ms
87,856 KB
testcase_09 AC 93 ms
83,436 KB
testcase_10 AC 110 ms
100,156 KB
testcase_11 AC 101 ms
93,084 KB
testcase_12 AC 114 ms
103,380 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 120 ms
83,948 KB
testcase_24 AC 157 ms
112,372 KB
testcase_25 AC 114 ms
106,304 KB
testcase_26 AC 86 ms
77,692 KB
testcase_27 AC 1,573 ms
141,796 KB
testcase_28 AC 173 ms
110,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def div(n):
    if n <= 0:
        return []
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    return list(S)

N, M = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
L = [0] * (M + 1)
D = [0] * (M + 1)
for a in A:
    D[a] += 1
    
dic = dict()
for i in range(1, M + 1):
    if D[i] == 0:
        continue
    dic[i] = div(i)
    for d in dic[i]:
        L[d] += D[i]
        
two = [1] * 202020
for i in range(202000):
    two[i + 1] = two[i] * 2
    two[i + 1] %= mod
    
ans = [0] * (M + 1)
for i in range(M + 1):
    ans[i] = two[L[i]] - 1
    
for i in range(M, 0, -1):
    if ans[i] == 0:
        continue
    for d in dic[i]:
        if d == i:
            continue
        ans[d] -= ans[i]
        ans[d] %= mod

for i in range(1, M + 1):
    print(ans[i])
0