Submission #494332

#TimeUsernameProblemLanguageResultExecution timeMemory
494332Christopher_Savrsen (COCI17_savrsen)C++17
120 / 120
1188 ms78544 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

int Abs(int x) {
    return x > 0 ? x : -x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    vector<ll> dp(b + 1);
    for (int i = 1; i <= b; ++i) {
        for (int j = i * 2; j <= b; j += i) {
            dp[j] += i;
        }
    }
    ll res = 0;
    for (int i = a; i <= b; ++i) {
        res += Abs(i - dp[i]);
    }
    cout << res << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...