結果
問題 |
No.2075 GCD Subsequence
|
ユーザー |
|
提出日時 | 2022-09-17 14:02:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 585 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 114,688 KB |
最終ジャッジ日時 | 2024-12-22 00:46:17 |
合計ジャッジ時間 | 7,323 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 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)