結果

問題 No.2211 Frequency Table of GCD
ユーザー roarisroaris
提出日時 2023-02-18 03:57:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 143,308 KB
最終ジャッジ日時 2023-09-27 00:19:28
合計ジャッジ時間 10,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,656 KB
testcase_01 AC 96 ms
71,784 KB
testcase_02 AC 96 ms
71,664 KB
testcase_03 AC 233 ms
82,168 KB
testcase_04 AC 274 ms
105,120 KB
testcase_05 AC 315 ms
117,296 KB
testcase_06 AC 268 ms
99,524 KB
testcase_07 AC 333 ms
114,700 KB
testcase_08 AC 119 ms
87,612 KB
testcase_09 AC 114 ms
82,940 KB
testcase_10 AC 135 ms
100,328 KB
testcase_11 AC 125 ms
93,232 KB
testcase_12 AC 138 ms
103,636 KB
testcase_13 AC 253 ms
100,100 KB
testcase_14 AC 277 ms
97,544 KB
testcase_15 AC 266 ms
90,100 KB
testcase_16 AC 271 ms
96,416 KB
testcase_17 AC 304 ms
112,832 KB
testcase_18 AC 445 ms
128,856 KB
testcase_19 AC 438 ms
128,956 KB
testcase_20 AC 443 ms
128,832 KB
testcase_21 AC 435 ms
129,080 KB
testcase_22 AC 432 ms
128,948 KB
testcase_23 AC 202 ms
82,204 KB
testcase_24 AC 243 ms
108,708 KB
testcase_25 AC 141 ms
107,100 KB
testcase_26 AC 97 ms
71,612 KB
testcase_27 AC 341 ms
143,308 KB
testcase_28 AC 244 ms
108,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
mp = Counter(A)
cnt = [0]*(M+1)

for d in range(1, M+1):
    for x in range(d, M+1, d):
        cnt[d] += mp[x]
        
ans = [0]*(M+1)
MOD = 998244353
pow2 = [1]*(N+10)

for i in range(1, N+10):
    pow2[i] = pow2[i-1]*2%MOD

for d in range(M, 0, -1):
    ans[d] = (pow2[cnt[d]]-1)%MOD
    
    for x in range(2*d, M+1, d):
        ans[d] -= ans[x]
        ans[d] %= MOD

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