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;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
int n;
cin >> n;
vector<int> D(n), X(n);
vector<ll> dp(n);
ll sum = 1;
for (int i = 0; i < n; i++) {
cin >> D[i] >> X[i];
if (i == 0) {
dp[i] = 1;
sum += dp[i];
continue;
}
for (int j = 0; j < i; j++) {
if (i <= j + X[j] && D[j] && ((i - j) % D[j] == 0)) {
dp[i] += dp[j];
dp[i] %= mod;
}
}
sum += dp[i];
sum %= mod;
}
cout << sum;
}
# | 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... |