This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5;
const int MOD = 1e9 + 7;
int d[MAX_N + 1], x[MAX_N + 1], dp[MAX_N + 1];
int main() {
int n;
cin >> n;
for ( int i = 1; i <= n; i++ )
cin >> d[i] >> x[i];
dp[1] = 1;
for ( int i = 1; i <= n; i++ ) {
if ( d[i] == 0 )
continue;
for ( int j = i + d[i]; j <= n && j <= i + (long long)x[i] * d[i]; j += d[i] )
dp[j] = (dp[j] + dp[i]) % MOD;
}
int ans = 0;
for ( int i = 1; i <= n; i++ )
ans = (ans + dp[i]) % MOD;
cout << ans;
return 0;
}
# | 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... |