結果

問題 No.2211 Frequency Table of GCD
コンテスト
ユーザー n_bitand_n_per_3
提出日時 2026-07-20 19:12:15
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 523 ms / 2,000 ms
+ 815µs
コード長 513 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 235 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 116,992 KB
最終ジャッジ日時 2026-07-20 19:12:26
合計ジャッジ時間 10,262 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import isqrt
MOD = 998244353

def divsor(x):
  arr = []
  for i in range(1,isqrt(x)+1):
    if x % i == 0:
      arr.append(i)
      if i*i != x:
        arr.append(x//i)
  return arr
    
N,M = map(int,input().split())
A = list(map(int,input().split()))

cnt = [0]*(M+1)
for a in A:
  for d in divsor(a):
    if d <= M:
      cnt[d] += 1

dp = [pow(2,cnt[i],MOD)-1 for i in range(M+1)]

for i in range(M,0,-1):
  for k in range(2*i,M+1,i):
    dp[i] -= dp[k]

for a in dp[1:]:
  print(a%MOD)










0