This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 100001
const ll M=1e9+7;
vector<int> a[N];
map<int,int> x[N];
map<int,int> y[N];
map<int,int> dp[N];
void solve(){
int n,m,o;
ll p,q;
cin>>n;
m=0;
for(int i=1;i<=n;i++){
o=(i==1);
cin>>p>>q;
q=min(q,1ll*n);
for(auto& j:a[i])
o=(o+dp[j][i%j])%M;
m=(m+o)%M;
if(p && q && p<n){
y[p][i%p]=max(i,y[p][i%p]);
for(int j=y[p][i%p]+p;j<=min(1ll*n,i+p*q);j+=p)
a[j].append(p);
y[p][i%p]=min(1ll*n+1,i+p*q);
dp[p][i%p]=(dp[p][i%p]+o)%M;
x[i+p*q][p]=(x[i+p*q][p]+o)%M;
}
for(auto& j:x[i])
dp[j.ff][i%j.ff]=(dp[j.ff][i%j.ff]+M-j.ss)%M;
}
cout<<m;
}
int terminator(){
L0TA;
solve();
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... |