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 maxn = 100005;
const int mod = 1e9 + 7;
int n;
int d[maxn], x[maxn];
int dp[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> d[i] >> x[i];
}
dp[1] = 1;
int ans = 1;
for (int i = 2; i <= n; ++i)
{
for (int j = i - 1; j >= 1; --j)
{
if (d[j] != 0 && (i - j) % d[j] == 0 && (i - j) / d[j] <= x[j])
{
dp[i] += dp[j];
if (dp[i] >= mod) dp[i] -= mod;
}
}
ans += dp[i];
if (ans >= mod) ans -= mod;
}
cout << ans << endl;
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... |