結果

問題 No.2211 Frequency Table of GCD
ユーザー roarisroaris
提出日時 2023-02-18 03:53:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,585 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 2,409 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 108,100 KB
最終ジャッジ日時 2023-09-27 00:16:10
合計ジャッジ時間 22,988 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,552 KB
testcase_01 AC 75 ms
71,780 KB
testcase_02 AC 76 ms
71,488 KB
testcase_03 AC 175 ms
81,428 KB
testcase_04 AC 571 ms
91,040 KB
testcase_05 AC 877 ms
101,004 KB
testcase_06 AC 528 ms
89,352 KB
testcase_07 AC 876 ms
98,444 KB
testcase_08 AC 122 ms
87,204 KB
testcase_09 AC 109 ms
82,808 KB
testcase_10 AC 155 ms
98,964 KB
testcase_11 AC 133 ms
92,096 KB
testcase_12 AC 159 ms
102,072 KB
testcase_13 AC 494 ms
89,592 KB
testcase_14 AC 502 ms
88,348 KB
testcase_15 AC 349 ms
84,436 KB
testcase_16 AC 474 ms
87,884 KB
testcase_17 AC 788 ms
98,164 KB
testcase_18 AC 1,279 ms
107,784 KB
testcase_19 AC 1,512 ms
108,004 KB
testcase_20 AC 1,287 ms
107,872 KB
testcase_21 AC 1,277 ms
108,100 KB
testcase_22 AC 1,280 ms
107,880 KB
testcase_23 AC 159 ms
80,956 KB
testcase_24 AC 1,544 ms
107,832 KB
testcase_25 AC 116 ms
105,840 KB
testcase_26 AC 75 ms
71,100 KB
testcase_27 AC 1,457 ms
107,992 KB
testcase_28 AC 1,585 ms
107,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

for Ai in A:
    for d in range(1, int(Ai**0.5)+1):
        if Ai%d==0:
            cnt[d] += 1
            
            if d!=Ai//d:
                cnt[Ai//d] += 1

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