#P15742. [JAG 2024 Summer Camp #2] Noncoprime Subsequences

[JAG 2024 Summer Camp #2] Noncoprime Subsequences

题目描述

Given a sequence A=(A1,A2,,AN)\boldsymbol{A} = (A_1, A_2, \ldots, A_N), a good subsequence of A\boldsymbol{A} is defined as a subsequence, that is not necessarily contiguous, where adjacent elements in the subsequence are not coprime.

Find the maximum length LL of a good subsequence of A\boldsymbol{A}. Also, determine the number of good subsequences of length LL, modulo 998,244,353998,244,353.

输入格式

The input is given in the following format:

$$\begin{aligned} &N \\ &A_1 \ A_2 \ \ldots \ A_N \end{aligned} $$
  • 1N200,0001 \leq N \leq 200,000
  • 1Ai1061 \leq A_i \leq 10^6
  • All input values are integers.

输出格式

Output 2 lines. On the first line, output LL. On the second line, output the number of good subsequences of length LL of A\boldsymbol{A}, modulo 998,244,353998,244,353.

3
2 3 6
2
2
5
1 1 1 1 1
1
5
10
631932 735902 895728 78537 723857 330739 286918 329211 539679 238506
7
2