其他分享
首页 > 其他分享> > C - Multiplicity CodeForces - 1061C(因子筛+线性dp)

C - Multiplicity CodeForces - 1061C(因子筛+线性dp)

作者:互联网

Multiplicity 

CodeForces - 1061C

Time limit 3000 ms Memory limit 262144 kB

Problem Description

You are given an integer array a1,a2,…,an.

The array bb is called to be a subsequence of aa if it is possible to remove some elements from aa to get b.

Array b1,b2,…,bk is called to be good if it is not empty and for every i (1≤i≤k) bibi is divisible by i.

Find the number of good subsequences in aa modulo 10^9+7.

Two subsequences are considered different if index sets of numbers included in them are different. That is, the values ​of the elements ​do not matter in the comparison of subsequences. In particular, the array aa has exactly 2n−1 different subsequences (excluding an empty subsequence).

 

Input

The first line contains an integer n (1≤n≤100000) — the length of the array aa.

The next line contains integers a1,a2,…,an (1≤ai≤10^6).

 

Output

Print exactly one integer — the number of good subsequences taken modulo 10^9+7.

 

Examples

Input
2
1 2
Output
3

Input
5
2 2 1 22 14
Output
13

Note

In the first example, all three non-empty possible subsequences are good: {1}{1}, {1,2}{1,2}, {2}{2}

In the second example, the possible good subsequences are: {2}{2}, {2,2}{2,2}, {2,22}{2,22}, {2,14}{2,14}, {2}{2}, {2,22}{2,22}, {2,14}{2,14}, {1}{1}, {1,22}{1,22}, {1,14}{1,14}, {22}{22}, {22,14}{22,14}, {14}{14}.

Note, that some subsequences are listed more than once, since they occur in the original array multiple times.

Solution:

首先看到这个mod 1e9+7,就勾起我不好的回忆了,费马小定理(大质数),NNT(原根),dp(线性/背包/树形/区间),矩阵快速幂

然后数据范围 10w,应该是设计个O(n)的算法吧(感觉自己已经边得很玄学了=_=!

标签:1061C,14,22,Multiplicity,ll,CodeForces,因子,subsequences,dp
来源: https://www.cnblogs.com/SayGB/p/10397797.html