AT_ndpc2026_l.LCM

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a positive integer NN and a permutation A=(A1,A2,…,AN)A = (A_1, A_2, \dots, A_N) of (1,2,…,N)(1, 2, \dots, N).

Consider a directed graph GG with NN vertices numbered from 11 to NN. For every pair of integers (i,j)(i, j) such that 1≤i<j≤N1 \leq i < j \leq N, there are LCM(Ai,Aj)\mathrm{LCM}(A_i, A_j) directed edges from vertex ii to vertex jj. (Here, LCM\mathrm{LCM} denotes the least common multiple.) There are no other edges in GG.

For each v=2,3,…,Nv = 2, 3, \dots, N, find the number of paths from vertex 11 to vertex vv, modulo 998244353998244353. Here, two paths are considered different if the sets of edges they pass through are different.

给定一个正整数 NN 和 (1,2,…,N)(1, 2, \dots, N) 的一个排列 A=(A1,A2,…,AN)A = (A_1, A_2, \dots, A_N)。

考虑一个包含 NN 个顶点(编号为 11 到 NN)的有向图 GG。对每一对满足 1≤i<j≤N1 \leq i < j \leq N 的整数 (i,j)(i, j),从顶点 ii 到顶点 jj 恰好有 LCM(Ai,Aj)\mathrm{LCM}(A_i, A_j) 条有向边。(此处 LCM\mathrm{LCM} 表示最小公倍数。)图 GG 中不存在其他边。

对每个 v=2,3,…,Nv = 2, 3, \dots, N,求从顶点 11 到顶点 vv 的路径条数,结果对 998244353998244353 取模。注意:若两条路径经过的边集不同,则视为不同的路径。

输入格式

The input is given from standard input in the following format:

NN
A1A_1 A2A_2 …\dots ANA_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\dots ANA_N

输出格式

Print N−1N-1 lines. On the ii-th line, output the answer for v=i+1v = i+1.

输出 N−1N-1 行。在第 ii 行中,输出 v=i+1v = i+1 时的答案。

输入输出样例

  • 输入#1

    4
    3 2 1 4

    输出#1

    6
    15
    96
  • 输入#2

    13
    12 3 2 4 10 9 5 8 1 6 11 7 13

    输出#2

    12
    84
    492
    11100
    1018368
    45948480
    913466263
    559040529
    720204824
    935993195
    339767199
    889449065

说明/提示

Sample 1 Explanation:
The directed edges in GG are as follows:

  • From vertex 11 to vertex 22: 66 edges
  • From vertex 11 to vertex 33: 33 edges
  • From vertex 11 to vertex 44: 1212 edges
  • From vertex 22 to vertex 33: 22 edges
  • From vertex 22 to vertex 44: 44 edges
  • From vertex 33 to vertex 44: 44 edges

Constraints

  • 2≤N≤2×1052 \leq N \leq 2 \times 10^5
  • (A1,A2,…,AN)(A_1, A_2, \dots, A_N) is a permutation of (1,2,…,N)(1, 2, \dots, N)
  • All input values are integers

样例 1 解释:
图 GG 中的有向边如下所示:

  • 从顶点 11 到顶点 22:66 条边
  • 从顶点 11 到顶点 33:33 条边
  • 从顶点 11 到顶点 44:1212 条边
  • 从顶点 22 到顶点 33:22 条边
  • 从顶点 22 到顶点 44:44 条边
  • 从顶点 33 到顶点 44:44 条边

约束条件

  • 2≤N≤2×1052 \leq N \leq 2 \times 10^5
  • (A1,A2,…,AN)(A_1, A_2, \dots, A_N) 是 (1,2,…,N)(1, 2, \dots, N) 的一个排列
  • 所有输入值均为整数

输入解题思路,AI测评打分。不知道怎么写?

首页