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 ff first
#define int long long
#define ss second
#define pb push_back
const int N=3e5+5;
const int mod=1e9+7;
int cnt[N];
std::vector<int>v[N],vc[N];
int dp[N];
signed main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int d,x;
cin>>d>>x;
if(d==0)continue;
for(int j=1;j<=x;j++){
if(i+d*j>n)break;
v[i].pb(i+d*j);
vc[i+d*j].pb(i);
}
}
dp[1]=1;
for(int i=2;i<=n;i++){
for(auto b:vc[i]){
dp[i]+=dp[b];
dp[i]%=mod;
}
}
int ans=0;
for(int i=1;i<=n;i++){
ans+=dp[i];
ans%=mod;
}
cout<<ans;
}
# | 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... |