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 N = 1e5+5;
const int mod = 1e9+7;
int dp[N];//number of paths starting from i
int main() {
int n;
cin>>n;
int a[n+1],b[n+1];
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
for(int i=n;i>0;i--){
dp[i]=1;
if(!a[i])continue;
for(int j=1;j<=b[i];j++){
int pos=i+j*a[i];
if(pos>n)break;
dp[i]=(dp[i]+dp[pos])%mod;
}
}
cout<<dp[1]<<'\n';
}
# | 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... |