Count of paths
Practice
2 (2 votes)
Algorithms
Hard
Square root decomposition
Problem
70% Success 1077 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given a sequence \(a_1{\dots}a_n\). It's guaranteed that \(a_i|m\) for all i, means every element in the sequence divides \(m\).

A graph is built with this sequence. Specifically, an edge \((u,v)\) exists when and only when \(u<v\) and \(a_u|a_v\). Obviously, this is a DAG.

Your task is to calculate the count of different paths from 1 to i for all i between 1 and n.

Input

The first line contains two integers, \(n\) and \(m\).

The second line contains \(n\) integers, representing the sequence \(a_1{\dots}a_n\).

It's guaranteed that \(a_1=1\).

Output

\(n\) lines. Each line contains an integer, the \(i_{th}\) integer is the count of different paths from 1 to i modulo \(10^9+7\).

Constraints

\(1\le n\le 2 \times 10^5\)

\(1\le m\le 10^{19}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
5 votes
Tags:
Square Root DecompositionAlgorithmsAdvanced Algorithms
Points:50
1 votes
Tags:
AlgorithmsApprovedHardSqrt-Decomposition
Points:50
5 votes
Tags:
Advanced AlgorithmsAlgorithmsC++Square Root Decomposition