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;
int main()
{
int n;
cin >> n;
long long int dp[n + 2];
long long int con=250;
long long int bo[n + 2][con];
long long int mod = 1e9 + 7;
for(int i = 0; i <= n;i++){
dp[i] = 0;
for(int j = 0; j < con; j++){
bo[i][j] = 0;
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j < con; j++){
dp[i] = (dp[i] + bo[i][j])% mod;
}
if(i == 1){
dp[i] = 1;
}
long long int d,x;
cin >> d >> x;
if(d >= con){
long long int to = i + d;
while(to <= n){
dp[to] = (dp[to] + dp[i])%mod;
to = to + d;
}
}else{
bo[i][d] = (bo[i][d] + dp[i])% mod;
long long int to = i + (x + 1) * d;
if(to <= n){
bo[to][d] = (bo[to][d] - dp[i] + mod)% mod;
}
}
for(int j = 1; j < con; j++){
if((i + j) <= n){
bo[i + j][j] = (bo[i + j][j] + bo[i][j])%mod;
}
}
}
long long int sum = 0;
for(int i = 1; i <= n; i++){
sum = (sum + dp[i])% 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... |