結果

問題 No.2211 Frequency Table of GCD
ユーザー 👑 KazunKazun
提出日時 2023-02-10 21:38:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 109,448 KB
最終ジャッジ日時 2023-09-22 01:00:35
合計ジャッジ時間 6,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,496 KB
testcase_01 AC 67 ms
71,636 KB
testcase_02 AC 68 ms
71,432 KB
testcase_03 AC 142 ms
82,436 KB
testcase_04 AC 144 ms
92,300 KB
testcase_05 AC 165 ms
101,772 KB
testcase_06 AC 150 ms
87,964 KB
testcase_07 AC 175 ms
99,384 KB
testcase_08 AC 84 ms
85,372 KB
testcase_09 AC 78 ms
81,052 KB
testcase_10 AC 95 ms
97,564 KB
testcase_11 AC 88 ms
90,500 KB
testcase_12 AC 98 ms
100,384 KB
testcase_13 AC 137 ms
88,656 KB
testcase_14 AC 155 ms
87,056 KB
testcase_15 AC 146 ms
83,748 KB
testcase_16 AC 149 ms
86,892 KB
testcase_17 AC 160 ms
98,984 KB
testcase_18 AC 192 ms
109,192 KB
testcase_19 AC 190 ms
109,260 KB
testcase_20 AC 191 ms
109,192 KB
testcase_21 AC 192 ms
109,184 KB
testcase_22 AC 190 ms
109,448 KB
testcase_23 AC 142 ms
82,800 KB
testcase_24 AC 178 ms
109,048 KB
testcase_25 AC 99 ms
103,812 KB
testcase_26 AC 67 ms
71,392 KB
testcase_27 AC 183 ms
109,264 KB
testcase_28 AC 180 ms
109,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    X=[0]*(M+1)
    for a in A:
        X[a]+=1

    B=[0]*(M+1); Mod=998244353
    for k in range(M,0,-1):
        count=0
        for a in range(k, M+1, k):
            count+=X[a]
        B[k]=pow(2,count,Mod)-1

        for a in range(2*k, M+1, k):
            B[k]-=B[a]

        B[k]%=Mod

    return B[1:]

#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

write("\n".join(map(str,solve())))
0