Submission #1085829

#TimeUsernameProblemLanguageResultExecution timeMemory
1085829andrewpSavrsen (COCI17_savrsen)C++14
120 / 120
595 ms78932 KiB
//Dedicated to my love, ivaziva
#include <bits/stdc++.h>
using namespace std;   

#define int long long 

using pii = pair<int, int>;
using ll = int64_t;    

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';    

int sum[10000005];

int32_t main() { 
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cout.tie(nullptr); cerr.tie(nullptr); 

    int a, b;
    cin >> a >> b;
    for (int i = 2; i < 10000001; i++) {
        for (int j = i + i; j < 10000001; j += i) {
            sum[j] += i;
        }
    }   
    int ans = 0; 
    for (int i = a; i <= b; i++) {
        if (i == 1) {
            ans += abs(i - sum[i]);
        } else {
            ans += abs(i - sum[i] - 1);
        }
    }
    cout << ans << '\n';
    return 0;                  
}
#Verdict Execution timeMemoryGrader output
Fetching results...