이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// EDU
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ins insert
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
int nxt(){ int x;cin>>x; return x; }
const int mod = 1e9 +7, sze = 1e5 +10, inf = LLONG_MAX, LG = 20;
const int B= 555;
int pref[B][B];
int event[sze][B],dp[sze];
void nev(int pos,int jump,int val){
if(pos>=sze){
return;
}
val=(val + mod)%mod;
event[pos][jump]+=val;
}
void rush(){
int n;
cin>>n;
vector<pair<int,int>> arr(n+1);
for(int i=1;i<=n;i++){
cin>>arr[i].first>>arr[i].second;
}
dp[1]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<B;j++){
pref[ i%j ][j] = ( pref[i%j][j] + event[i][j] + mod)%mod;
dp[i]=(dp[i] + pref[i%j][j] + mod)%mod;
}
if( arr[i].first){
if(arr[i].first >= B){
for(int j = arr[i].first + i, c = 1;c<=arr[i].second, j<=n; j+=arr[i].first, c++){
dp[j]= (dp[j] + dp[i] + mod)%mod;
}
}
else{
nev(i + arr[i].first, arr[i].first, dp[i]);
nev( i + arr[i].first * (1+arr[i].second), arr[i].first, -dp[i]);
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
ans=(ans+dp[i])%mod;
}
putr(ans);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
rush();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void rush()':
Main.cpp:42:54: warning: value computed is not used [-Wunused-value]
42 | for(int j = arr[i].first + i, c = 1;c<=arr[i].second, j<=n; j+=arr[i].first, c++){
| ~^~~~~~~~~~~~~~~
# | 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... |