結果

問題 No.2211 Frequency Table of GCD
ユーザー ntudantuda
提出日時 2023-02-13 18:03:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 111,084 KB
最終ジャッジ日時 2023-09-23 11:53:25
合計ジャッジ時間 6,770 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,432 KB
testcase_01 AC 73 ms
71,388 KB
testcase_02 AC 73 ms
71,328 KB
testcase_03 AC 148 ms
80,872 KB
testcase_04 AC 154 ms
92,756 KB
testcase_05 AC 172 ms
102,660 KB
testcase_06 AC 156 ms
88,648 KB
testcase_07 AC 179 ms
100,516 KB
testcase_08 AC 90 ms
85,796 KB
testcase_09 AC 84 ms
81,324 KB
testcase_10 AC 102 ms
98,204 KB
testcase_11 AC 95 ms
91,004 KB
testcase_12 AC 106 ms
101,320 KB
testcase_13 AC 146 ms
89,724 KB
testcase_14 AC 162 ms
87,432 KB
testcase_15 AC 150 ms
84,720 KB
testcase_16 AC 157 ms
87,636 KB
testcase_17 AC 168 ms
100,316 KB
testcase_18 AC 197 ms
110,892 KB
testcase_19 AC 197 ms
110,956 KB
testcase_20 AC 197 ms
110,820 KB
testcase_21 AC 196 ms
111,020 KB
testcase_22 AC 199 ms
111,084 KB
testcase_23 AC 147 ms
80,684 KB
testcase_24 AC 189 ms
110,764 KB
testcase_25 AC 106 ms
104,284 KB
testcase_26 AC 73 ms
71,404 KB
testcase_27 AC 191 ms
111,052 KB
testcase_28 AC 187 ms
110,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

F = [0] * (M + 1)
G = [0] * (M + 1)

for a in A:
    F[a] += 1

fcnt = 0
for i in reversed(range(1, M + 1)):
    fcnt = F[i]
    gcnt = 0
    for j in range(2 * i, M + 1, i):
        fcnt += F[j]
        gcnt += G[j]
    tmp = pow(2, fcnt, MOD) - 1 - gcnt
    G[i] = tmp % MOD

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