Submission #1047524

#TimeUsernameProblemLanguageResultExecution timeMemory
104752412345678Savrsen (COCI17_savrsen)C++17
60 / 120
50 ms131072 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e7+5;

ll a, b, res, p[nx], dp[nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>a>>b;
    for (int i=1; i<=b; i++) dp[i]=1;
    for (int i=2; i<=b; i++)
    {
        if (p[i]) continue;
        for (int j=i; j<=b; j+=i)
        {
            p[j]=1;
            ll vl=j, tmp=1, mul=i;
            while ((vl%mul)==0) tmp+=mul, mul*=i;
            dp[j]*=tmp;
        }
    }
    //for (int i=1; i<=b; i++) cout<<"debug "<<dp[i]<<'\n';
    for (int i=a; i<=b; i++) res+=abs(dp[i]-2*i);
    cout<<res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...