Submission #1350459

#TimeUsernameProblemLanguageResultExecution timeMemory
1350459hanguyendanghuySavrsen (COCI17_savrsen)C++20
120 / 120
521 ms78716 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
const ll MAXN=1e7+5,MOD=1e9+7,INF=1e18,LG=16,MAX=1e7;
ll i,n,m,j,k,p,t,a[MAXN],nt[MAXN],luu[MAXN];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll l,r;
    cin>>l>>r;
    for(i=1;i<=MAX;i++){
        for(j=i*2;j<=MAX;j+=i)
            nt[j]+=i;
    }
    ll ans=0;
    for(i=l;i<=r;i++){
        ans+=abs(i-nt[i]);
    }
    cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...