이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~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;
for(auto& j:a[i])
o=(o+dp[j][i%j])%M;
m=(m+o)%M;
if(p) q=n/p;
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[min(1ll*n,i+p*q)][p]=(x[min(1ll*n,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... |