#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define all(x) begin(x), end(x)
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
template<typename T>
using vec = vector<T>;
template<typename T, size_t N>
using arr = array<T, N>;
const ll INF = 1e17;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vec<int> d(N + 1), x(N + 1);
vec<ll> dp(N + 1);
for (int i = 1; i <= N; i++)
cin >> d[i] >> x[i];
dp[1] = 1;
ll ans = 0;
for (int i = 1; i <= N; i++) {
ans = (ans + dp[i]) % MOD;
if (d[i] == 0) continue;
for (int t = 1; t <= x[i]; t++) {
int y = i + t * d[i];
if (y > N) break;
dp[y] = (dp[y] + dp[i]) % MOD;
}
}
cout << ans << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |