問題一覧 > 通常問題

No.2075 GCD Subsequence

レベル : / AI推定難易度 : 1950 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 70
作問者 : taiga0629kyopro / テスター : 夕叢霧香(ゆうむらきりか)
お気に入りにしたユーザー ProblemId : 8399 / 自分の提出
問題文最終更新日: 2022-09-16 18:00:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 360 (順位表) の他の問題:

Problem Statement

$\mathrm{gcd}(x,y)$ denotes the greatest common divisor of $x$ and $y$.

You are given an integer sequence $A$ of length $N$. Find the number of subsequences $A'=(A'_1,A'_2,\dots , A'_k)$ of $A$, not necessarily contiguous, of length at least $1$, that satisfy the following condition.

  • For every integer $i$ satisfying $1 \le i \le k-1$, $\mathrm{gcd}(A'_i,A'_{i+1})>1$

Since the answer can be very large, output the answer modulo $998244353$.

Two subsequences are distinguished if the indices they are taken from differ, even if they are the same as sequences.

Input

$N$
$A_1$ $A_2$ $\dots$ $A_N$

  • $1 \le N \le 2×10^5$
  • $1 \le A_i \le 10^6 $
  • All inputs are integers.
  • Output

    Output the number of subsequences satisfying the condition, modulo $998244353$.

    Sample

    Sample 1
    Input
    4
    1 2 3 4
    Output
    5

    The subsequences satisfying the condition are the following 5: $(1),(2),(3),(4),(2,4)$.

    Sample 2
    Input
    1
    1
    Output
    1

    Sample 3
    Input
    10
    3 1 7 5 4 10 8 6 2 9
    Output
    58

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。