-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathc.cc
More file actions
32 lines (29 loc) · 683 Bytes
/
c.cc
File metadata and controls
32 lines (29 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// https://codeforces.com/contest/1061/problem/C
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int N = 1000000;
int M = 1e9+7;
int main() {
ios::sync_with_stdio(0);
cin.tie();
int n, x;
cin >> n;
vvi d(N + 1);
for (int i = 1; i <= N; i++)
for (int j = i; j <= N; j += i)
d[j].push_back(i);
vi r(1, 1);
for (int i = 0; i < n; i++) {
cin >> x;
for (int j = d[x].size() - 1; j >= 0; j--) {
int y = d[x][j];
if (r.size() == y) r.push_back(r[y - 1]);
else if (r.size() > y) (r[y] += r[y - 1]) %= M;
}
}
int s = r[0] = 0;
for (int x : r) (s += x) %= M;
cout << s << '\n';
}