結果

問題 No.2075 GCD Subsequence
ユーザー dn6049949dn6049949
提出日時 2022-09-16 22:40:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,196 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 95,592 KB
最終ジャッジ日時 2023-08-23 16:15:30
合計ジャッジ時間 14,595 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,584 KB
testcase_01 AC 90 ms
71,688 KB
testcase_02 AC 92 ms
71,716 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 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 93 ms
71,460 KB
testcase_30 AC 92 ms
71,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 998244353


def factorize(n):
    res = {}
    p = 2
    while 1:
        if p*p > n:
            break
        if n%p:
            p += 1
            continue
        s = 0
        while n%p == 0:
            n //= p
            s += 1
        res[p] = s
        p += 1

    if n > 1:
        res[n] = 1
    return res


def main():
    n = I()
    a = LI()
    ans = 0
    su = defaultdict(lambda: 0)
    for i in a:
        f = factorize(i)
        s = 1
        for i in f.keys():
            s += su[i]
            if s >= mod:
                s -= mod
        for i in f.keys():
            su[i] += s
            if su[i] >= mod:
                su[i] -= mod
        ans += s
        if ans >= mod:
            ans -= mod
    print(ans)
    return


if __name__ == "__main__":
    main()
0