QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#14414. 美妙的子序列

统计

给定一个序列 $a = (a_1, a_2, \dots, a_n)$。$a$ 的一个极好子序列是指一个子序列(不一定连续),其中相邻的元素不互质。

求 $a$ 的极好子序列的最大长度 $\ell$。此外,求长度为 $\ell$ 的极好子序列的数量,结果对 $998\,244\,353$ 取模。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 2 \cdot 10^5$)。

第二行包含序列 $a$,由 $n$ 个整数 $a_i$ ($1 \le a_i \le 10^6$) 组成。

输出格式

输出两行。

第一行输出 $\ell$。

第二行输出 $a$ 的长度为 $\ell$ 的极好子序列的数量,结果对 $998\,244\,353$ 取模。

样例

输入样例 1

3
2 3 6

输出样例 1

2
2

输入样例 2

5
1 1 1 1 1

输出样例 2

1
5

输入样例 3

10
631932 735902 895728 78537 723857 330739 286918 329211 539679 238506

输出样例 3

7
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.