結果

問題 No.2211 Frequency Table of GCD
ユーザー 👑 timitimi
提出日時 2023-02-11 16:11:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,957 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 131,328 KB
最終ジャッジ日時 2023-09-22 12:54:43
合計ジャッジ時間 25,242 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,108 KB
testcase_01 AC 72 ms
71,196 KB
testcase_02 AC 72 ms
71,204 KB
testcase_03 AC 214 ms
81,760 KB
testcase_04 AC 699 ms
98,584 KB
testcase_05 AC 1,087 ms
106,504 KB
testcase_06 AC 621 ms
96,728 KB
testcase_07 AC 1,033 ms
106,068 KB
testcase_08 AC 126 ms
86,328 KB
testcase_09 AC 117 ms
82,352 KB
testcase_10 AC 178 ms
98,760 KB
testcase_11 AC 143 ms
91,912 KB
testcase_12 AC 188 ms
102,000 KB
testcase_13 AC 576 ms
95,348 KB
testcase_14 AC 574 ms
95,396 KB
testcase_15 AC 399 ms
90,932 KB
testcase_16 AC 555 ms
93,824 KB
testcase_17 AC 981 ms
102,688 KB
testcase_18 AC 1,595 ms
117,072 KB
testcase_19 AC 1,866 ms
117,156 KB
testcase_20 AC 1,589 ms
116,848 KB
testcase_21 AC 1,606 ms
117,136 KB
testcase_22 AC 1,582 ms
119,424 KB
testcase_23 AC 104 ms
80,596 KB
testcase_24 AC 1,957 ms
107,612 KB
testcase_25 AC 135 ms
104,744 KB
testcase_26 AC 71 ms
71,192 KB
testcase_27 AC 1,774 ms
131,328 KB
testcase_28 AC 1,952 ms
107,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

D={}
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
E=[]
for a in A:
  AA=make_divisors(a)
  for b in AA:
    if b not in D:
      D[b]=0
      E.append(b)
    D[b]+=1

ans=[0]*(M+1)
mod=998244353 
E=sorted(E)[::-1]
dd=0
for e in E:
  d=D[e]
  p=(pow(2,d,mod)-1)%mod
  dd+=p
  ans[e]+=p
  ans[e]%=mod
  now=e 
  while now+e<=M:
    now+=e 
    ans[e]-=ans[now] 
    ans[e]%=mod 
ans=ans[1:]
for i in range(M):
  print(ans[i])
0