結果

問題 No.2211 Frequency Table of GCD
ユーザー FromBooskaFromBooska
提出日時 2023-09-01 19:19:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 118,324 KB
最終ジャッジ日時 2023-09-01 19:19:20
合計ジャッジ時間 11,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
71,800 KB
testcase_01 AC 78 ms
71,668 KB
testcase_02 AC 96 ms
71,588 KB
testcase_03 AC 215 ms
82,112 KB
testcase_04 AC 232 ms
93,584 KB
testcase_05 AC 279 ms
101,396 KB
testcase_06 AC 215 ms
89,800 KB
testcase_07 AC 311 ms
99,112 KB
testcase_08 AC 100 ms
86,380 KB
testcase_09 AC 93 ms
82,512 KB
testcase_10 AC 116 ms
98,904 KB
testcase_11 AC 107 ms
91,796 KB
testcase_12 AC 124 ms
103,624 KB
testcase_13 AC 218 ms
91,224 KB
testcase_14 AC 241 ms
89,960 KB
testcase_15 AC 269 ms
86,896 KB
testcase_16 AC 235 ms
90,956 KB
testcase_17 AC 284 ms
98,876 KB
testcase_18 AC 348 ms
107,564 KB
testcase_19 AC 360 ms
107,560 KB
testcase_20 AC 339 ms
107,552 KB
testcase_21 AC 343 ms
107,472 KB
testcase_22 AC 336 ms
107,560 KB
testcase_23 AC 138 ms
81,180 KB
testcase_24 AC 187 ms
107,520 KB
testcase_25 AC 121 ms
105,896 KB
testcase_26 AC 77 ms
71,592 KB
testcase_27 AC 263 ms
118,324 KB
testcase_28 AC 194 ms
107,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ABC162Eの考え方を使えるか
# Aの要素をCounter
# k=Mから降順で求める
# k=mとなるのはすべてがmの倍数の個数をべき乗数とた2のべき乗、引く、mの倍数のときのパターン巣

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

from collections import Counter
counted = Counter(A)
maxA = max(A)
patterns = [0]*(M+1)
mod = 998244353
for k in range(M, 0, -1):
    multiple_count = 0
    deduct = 0
    for j in range(k, maxA+1, k):
        multiple_count += counted[j]
        deduct += patterns[j]
    calc = 0
    if multiple_count > 0:
        calc += pow(2, multiple_count, mod)-1
    calc -= deduct
    #print('k', k, 'multiple_count', multiple_count, 'deduct', deduct, 'calc', calc)
    patterns[k] = calc%mod
    
#print(patterns)

for p in patterns[1:]:
    print(p)
0