結果
| 問題 | No.2075 GCD Subsequence | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-09-17 14:02:08 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 584 bytes | 
| コンパイル時間 | 756 ms | 
| コンパイル使用メモリ | 82,432 KB | 
| 実行使用メモリ | 114,688 KB | 
| 最終ジャッジ日時 | 2024-12-22 00:46:06 | 
| 合計ジャッジ時間 | 5,275 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 RE * 26 | 
ソースコード
n = int(input())
a = list(map(int,input().split()))
mod = 998244353
def e(n): #O(NloglogN)
  l = [i for i in range(n+1)]
  l[0] = 0
  l[1] = 1
  for i in range(2,n):
    if l[i] == i:
      for p in range(i+i,n+1,i):
        l[p] = i
  return l
l = e(10**6+10)
now = [0]*(10*6+10)
for ai in a[::-1]:
  s = set()
  aai = ai
  while aai != 1:
    s.add(l[aai])
    aai //= l[aai]
  
  tmp = 0
  cnt = 0
  for i in s:
    tmp += now[i]
    tmp %= mod
    cnt += 1
  now[ai] -= (cnt-1)*(tmp+1)
  now[ai] %= mod
  for i in s:
    now[i] += tmp+1
    now[i] %= mod
print(sum(now)%mod)
            
            
            
        