結果

問題 No.2211 Frequency Table of GCD
ユーザー qibqib
提出日時 2023-03-26 01:01:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 450 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 81,720 KB
実行使用メモリ 109,236 KB
最終ジャッジ日時 2023-10-19 08:55:06
合計ジャッジ時間 6,329 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,444 KB
testcase_01 AC 39 ms
53,444 KB
testcase_02 AC 40 ms
53,444 KB
testcase_03 AC 147 ms
85,920 KB
testcase_04 AC 135 ms
91,932 KB
testcase_05 AC 156 ms
101,072 KB
testcase_06 AC 142 ms
88,384 KB
testcase_07 AC 164 ms
98,712 KB
testcase_08 AC 55 ms
73,552 KB
testcase_09 AC 51 ms
69,168 KB
testcase_10 AC 69 ms
90,032 KB
testcase_11 AC 61 ms
80,796 KB
testcase_12 AC 72 ms
93,040 KB
testcase_13 AC 129 ms
88,796 KB
testcase_14 AC 147 ms
88,900 KB
testcase_15 AC 138 ms
87,056 KB
testcase_16 AC 142 ms
88,064 KB
testcase_17 AC 152 ms
98,136 KB
testcase_18 AC 189 ms
108,912 KB
testcase_19 AC 186 ms
108,912 KB
testcase_20 AC 185 ms
108,912 KB
testcase_21 AC 185 ms
108,912 KB
testcase_22 AC 188 ms
108,912 KB
testcase_23 AC 135 ms
86,660 KB
testcase_24 AC 172 ms
109,236 KB
testcase_25 AC 78 ms
98,052 KB
testcase_26 AC 40 ms
53,444 KB
testcase_27 AC 177 ms
108,912 KB
testcase_28 AC 171 ms
109,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n, m = map(int, input().split())
a = list(map(int, input().split()))

cnt = [0 for _ in range(m + 1)]
for x in a:
  cnt[x] += 1

mul = [0 for _ in range(m + 1)]
for x in range(1, m + 1):
  for y in range(x, m + 1, x):
    mul[x] += cnt[y]

dp = [0 for _ in range(m + 1)]
for x in range(m, 0, -1):
  dp[x] = (pow(2, mul[x], MOD) - 1) % MOD
  for y in range(2 * x, m + 1, x):
    dp[x] = (dp[x] - dp[y]) % MOD

print(*dp[1:], sep="\n")
0