結果

問題 No.2211 Frequency Table of GCD
ユーザー 👑 timitimi
提出日時 2023-02-11 15:30:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 123,156 KB
最終ジャッジ日時 2023-09-22 12:26:36
合計ジャッジ時間 31,190 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,456 KB
testcase_01 AC 74 ms
71,300 KB
testcase_02 AC 72 ms
71,300 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 134 ms
105,016 KB
testcase_26 AC 74 ms
71,148 KB
testcase_27 TLE -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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]
for a in A:
  AA=make_divisors(a)
  for b in AA:
    if b not in D:
      D[b]=0
    D[b]+=1
ans=[0]*M
mod=998244353 
for m in range(M,0,-1):
  if m not in D:
    continue
  d=D[m]
  p=(pow(2,d,mod)-1)%mod
  AA=make_divisors(m)[::-1]
  ans[AA[0]-1]+=p
  ans[AA[0]-1]%=mod
  for nex in AA[1:]:
    ans[nex-1]-=p 
    ans[nex-1]%=mod   
d=(pow(2,N,mod)-1-sum(ans[1:])%mod)%mod
ans[0]=d 
for i in ans:
  print(i)
0