| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1350454 | hanguyendanghuy | Savrsen (COCI17_savrsen) | C++20 | 1 ms | 836 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll int
#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=1e9,MAXV=1e7;
ll i,n,m,j,k,p,ans,cnt,dem,nt[MAXN];
long long luu[MAXN];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
freopen("HHH.inp","r",stdin);
freopen("HHH.out","w",stdout);
ll l,r;
cin>>l>>r;
luu[1]=1;
for(i=2;i*i<=r;i++){
if(!nt[i]){
for(j=i;j<=r;j+=i)
nt[j]=i;
}
}
for(i=2;i<=r;i++){
if(!nt[i]){
for(j=i;j<=r;j+=i)
nt[j]=i;
}
ll last=nt[i];
long long cur=1,m=i;
while(m%last==0){
cur*=last;
m/=last;
}
cur*=last;
luu[i]=luu[m]*((cur-1)/(last-1));
}
long long ans=0;
for(i=l;i<=r;i++){
luu[i]-=i;
ans+=abs(i-luu[i]);
}
cout<<ans;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
