AT_ndpc2026_l.LCM
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive integer N and a permutation A=(A1,A2,…,AN) of (1,2,…,N).
Consider a directed graph G with N vertices numbered from 1 to N. For every pair of integers (i,j) such that 1≤i<j≤N, there are LCM(Ai,Aj) directed edges from vertex i to vertex j. (Here, LCM denotes the least common multiple.) There are no other edges in G.
For each v=2,3,…,N, find the number of paths from vertex 1 to vertex v, modulo 998244353. Here, two paths are considered different if the sets of edges they pass through are different.
给定一个正整数 N 和 (1,2,…,N) 的一个排列 A=(A1,A2,…,AN)。
考虑一个包含 N 个顶点(编号为 1 到 N)的有向图 G。对每一对满足 1≤i<j≤N 的整数 (i,j),从顶点 i 到顶点 j 恰好有 LCM(Ai,Aj) 条有向边。(此处 LCM 表示最小公倍数。)图 G 中不存在其他边。
对每个 v=2,3,…,N,求从顶点 1 到顶点 v 的路径条数,结果对 998244353 取模。注意:若两条路径经过的边集不同,则视为不同的路径。
输入格式
The input is given from standard input in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
输出格式
Print N−1 lines. On the i-th line, output the answer for v=i+1.
输出 N−1 行。在第 i 行中,输出 v=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 G are as follows:
- From vertex 1 to vertex 2: 6 edges
- From vertex 1 to vertex 3: 3 edges
- From vertex 1 to vertex 4: 12 edges
- From vertex 2 to vertex 3: 2 edges
- From vertex 2 to vertex 4: 4 edges
- From vertex 3 to vertex 4: 4 edges
Constraints
- 2≤N≤2×105
- (A1,A2,…,AN) is a permutation of (1,2,…,N)
- All input values are integers
样例 1 解释:
图 G 中的有向边如下所示:
- 从顶点 1 到顶点 2:6 条边
- 从顶点 1 到顶点 3:3 条边
- 从顶点 1 到顶点 4:12 条边
- 从顶点 2 到顶点 3:2 条边
- 从顶点 2 到顶点 4:4 条边
- 从顶点 3 到顶点 4:4 条边
约束条件
- 2≤N≤2×105
- (A1,A2,…,AN) 是 (1,2,…,N) 的一个排列
- 所有输入值均为整数
输入解题思路,AI测评打分。不知道怎么写?