제출 #1166400

#제출 시각아이디문제언어결과실행 시간메모리
1166400sunflowerSavrsen (COCI17_savrsen)C++17
120 / 120
306 ms39576 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define SZ(x) ((int) (x).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define debug(x) cerr << "[" << #x << " = " << (x) << "]" << endl

#define left    __left
#define right   __right
#define prev    __prev
#define fi      first
#define se      second

template <class X, class Y>
    bool maximize(X &x, Y y) {
        if (x < y) return x = y, true;
        else return false;
    }

template <class X, class Y>
    bool minimize(X &x, Y y) {
        if (x > y) return x = y, true;
        else return false;
    }

int L, R;

#define MAX_N 10'000'100
int sumDiv[MAX_N + 2];

void sieve() {
    FOR(i, 1, trunc(sqrt(MAX_N))) {
        sumDiv[i * i] += i;
        FOR(j, i + 1, MAX_N / i) sumDiv[i * j] += i + j;
    }
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    sieve();

    cin >> L >> R;
    ll ans = 0;
    FOR(i, L, R) ans += abs(2 * i - sumDiv[i]);
    cout << ans;

    return 0;
}

/* Discipline - Calm */
#Verdict Execution timeMemoryGrader output
Fetching results...