#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5 + 10, mod = 1e9 + 7, D = 100;
ll n, dp[N], sm[D][D], a[N][2];
vector<ll> del[N];
void add(ll &x, ll y){
x += y;
if (x < 0) x += mod;
if (x >= mod) x -= mod;
}
int main(){
cin >> n;
for (ll i = 1; i <= n; i ++)
cin >> a[i][0] >> a[i][1];
dp[1] = 1;
for (ll i = 1; i <= n; i ++){
for (ll d = 1; d < D; d ++)
add(dp[i], sm[d][i % d]);
for (ll l : del[i])
add(sm[a[l][0]][l % a[l][0]], -dp[l]);
if (!a[i][0] or !a[i][1]) continue;
if (a[i][0] >= D){
for (ll j = i + a[i][0]; j <= n and a[i][1]; j += a[i][0], a[i][1]--)
add(dp[j], dp[i]);
}
else{
add(sm[a[i][0]][i % a[i][0]], dp[i]);
ll r = 1ll * i + 1ll * a[i][0] * a[i][1];
if (r <= n)
del[r].push_back(i);
}
}
ll ans = 0;
for (ll i = 1; i <= n; i ++)
add(ans, dp[i]);
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
0 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
0 ms |
4700 KB |
Output is correct |
9 |
Correct |
0 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
0 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
0 ms |
4700 KB |
Output is correct |
9 |
Correct |
0 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4708 KB |
Output is correct |
20 |
Correct |
4 ms |
4700 KB |
Output is correct |
21 |
Correct |
2 ms |
4700 KB |
Output is correct |
22 |
Correct |
5 ms |
4700 KB |
Output is correct |
23 |
Correct |
4 ms |
4696 KB |
Output is correct |
24 |
Correct |
2 ms |
4700 KB |
Output is correct |
25 |
Correct |
4 ms |
4700 KB |
Output is correct |
26 |
Correct |
2 ms |
4700 KB |
Output is correct |
27 |
Correct |
4 ms |
4696 KB |
Output is correct |
28 |
Correct |
5 ms |
4700 KB |
Output is correct |
29 |
Correct |
5 ms |
4700 KB |
Output is correct |
30 |
Correct |
5 ms |
4700 KB |
Output is correct |
31 |
Correct |
5 ms |
4728 KB |
Output is correct |
32 |
Correct |
5 ms |
4700 KB |
Output is correct |
33 |
Correct |
5 ms |
4700 KB |
Output is correct |
34 |
Correct |
5 ms |
4700 KB |
Output is correct |
35 |
Correct |
6 ms |
4700 KB |
Output is correct |
36 |
Correct |
5 ms |
4700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4700 KB |
Output is correct |
2 |
Correct |
3 ms |
4700 KB |
Output is correct |
3 |
Correct |
2 ms |
4700 KB |
Output is correct |
4 |
Correct |
4 ms |
4728 KB |
Output is correct |
5 |
Correct |
33 ms |
6492 KB |
Output is correct |
6 |
Correct |
47 ms |
4948 KB |
Output is correct |
7 |
Correct |
47 ms |
5460 KB |
Output is correct |
8 |
Correct |
1 ms |
4700 KB |
Output is correct |
9 |
Correct |
0 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
5 ms |
4700 KB |
Output is correct |
12 |
Correct |
49 ms |
4984 KB |
Output is correct |
13 |
Correct |
1 ms |
4696 KB |
Output is correct |
14 |
Correct |
5 ms |
4700 KB |
Output is correct |
15 |
Correct |
45 ms |
4948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4700 KB |
Output is correct |
2 |
Correct |
19 ms |
4724 KB |
Output is correct |
3 |
Correct |
47 ms |
4968 KB |
Output is correct |
4 |
Correct |
33 ms |
4948 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
5 ms |
4724 KB |
Output is correct |
8 |
Correct |
49 ms |
4976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
0 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
0 ms |
4700 KB |
Output is correct |
9 |
Correct |
0 ms |
4700 KB |
Output is correct |
10 |
Correct |
1 ms |
4700 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
1 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4700 KB |
Output is correct |
15 |
Correct |
1 ms |
4700 KB |
Output is correct |
16 |
Correct |
1 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
4700 KB |
Output is correct |
18 |
Correct |
1 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4708 KB |
Output is correct |
20 |
Correct |
4 ms |
4700 KB |
Output is correct |
21 |
Correct |
2 ms |
4700 KB |
Output is correct |
22 |
Correct |
5 ms |
4700 KB |
Output is correct |
23 |
Correct |
4 ms |
4696 KB |
Output is correct |
24 |
Correct |
2 ms |
4700 KB |
Output is correct |
25 |
Correct |
4 ms |
4700 KB |
Output is correct |
26 |
Correct |
2 ms |
4700 KB |
Output is correct |
27 |
Correct |
4 ms |
4696 KB |
Output is correct |
28 |
Correct |
5 ms |
4700 KB |
Output is correct |
29 |
Correct |
5 ms |
4700 KB |
Output is correct |
30 |
Correct |
5 ms |
4700 KB |
Output is correct |
31 |
Correct |
5 ms |
4728 KB |
Output is correct |
32 |
Correct |
5 ms |
4700 KB |
Output is correct |
33 |
Correct |
5 ms |
4700 KB |
Output is correct |
34 |
Correct |
5 ms |
4700 KB |
Output is correct |
35 |
Correct |
6 ms |
4700 KB |
Output is correct |
36 |
Correct |
5 ms |
4700 KB |
Output is correct |
37 |
Correct |
1 ms |
4700 KB |
Output is correct |
38 |
Correct |
3 ms |
4700 KB |
Output is correct |
39 |
Correct |
2 ms |
4700 KB |
Output is correct |
40 |
Correct |
4 ms |
4728 KB |
Output is correct |
41 |
Correct |
33 ms |
6492 KB |
Output is correct |
42 |
Correct |
47 ms |
4948 KB |
Output is correct |
43 |
Correct |
47 ms |
5460 KB |
Output is correct |
44 |
Correct |
1 ms |
4700 KB |
Output is correct |
45 |
Correct |
0 ms |
4700 KB |
Output is correct |
46 |
Correct |
1 ms |
4700 KB |
Output is correct |
47 |
Correct |
5 ms |
4700 KB |
Output is correct |
48 |
Correct |
49 ms |
4984 KB |
Output is correct |
49 |
Correct |
1 ms |
4696 KB |
Output is correct |
50 |
Correct |
5 ms |
4700 KB |
Output is correct |
51 |
Correct |
45 ms |
4948 KB |
Output is correct |
52 |
Correct |
24 ms |
4700 KB |
Output is correct |
53 |
Correct |
19 ms |
4724 KB |
Output is correct |
54 |
Correct |
47 ms |
4968 KB |
Output is correct |
55 |
Correct |
33 ms |
4948 KB |
Output is correct |
56 |
Correct |
1 ms |
4700 KB |
Output is correct |
57 |
Correct |
1 ms |
4700 KB |
Output is correct |
58 |
Correct |
5 ms |
4724 KB |
Output is correct |
59 |
Correct |
49 ms |
4976 KB |
Output is correct |
60 |
Correct |
39 ms |
4984 KB |
Output is correct |
61 |
Correct |
42 ms |
5200 KB |
Output is correct |
62 |
Correct |
40 ms |
7260 KB |
Output is correct |
63 |
Correct |
50 ms |
4968 KB |
Output is correct |
64 |
Correct |
59 ms |
4944 KB |
Output is correct |
65 |
Correct |
63 ms |
4952 KB |
Output is correct |
66 |
Correct |
48 ms |
5200 KB |
Output is correct |
67 |
Correct |
55 ms |
4956 KB |
Output is correct |
68 |
Correct |
53 ms |
4944 KB |
Output is correct |
69 |
Correct |
51 ms |
5928 KB |
Output is correct |
70 |
Correct |
46 ms |
4976 KB |
Output is correct |
71 |
Correct |
45 ms |
4948 KB |
Output is correct |
72 |
Correct |
71 ms |
5204 KB |
Output is correct |