답안 #856099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856099 2023-10-02T16:38:12 Z vjudge1 Savrsen (COCI17_savrsen) C++17
120 / 120
621 ms 39772 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 10000001
using namespace std;
const int mod=1000000007ll;

void solve(){
    int a,b;
    cin>>a>>b;
    static signed all[lim];
    memset(all,0,sizeof(all));
    all[1]=0;
    for(int i=2;i<lim;i++){
        all[i]++;
        for(int j=2*i;j<lim;j+=i){
            all[j]+=i;
        }
    }
    int ans=0;
    for(int i=a;i<=b;i++){
        //cerr<<abs(i-all[i])<<"\n";
        ans+=abs(i-all[i]);
    }
    cout<<ans<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 548 ms 39568 KB Output is correct
2 Correct 539 ms 39576 KB Output is correct
3 Correct 621 ms 39572 KB Output is correct
4 Correct 573 ms 39572 KB Output is correct
5 Correct 564 ms 39512 KB Output is correct
6 Correct 560 ms 39772 KB Output is correct
7 Correct 593 ms 39572 KB Output is correct
8 Correct 560 ms 39568 KB Output is correct