답안 #494331

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494331 2021-12-15T06:54:10 Z Christopher_ Savrsen (COCI17_savrsen) C++17
120 / 120
1047 ms 78540 KB
#include <bits/stdc++.h>
using namespace std;

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

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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 1100 KB Output is correct
4 Correct 1037 ms 78540 KB Output is correct
5 Correct 1047 ms 78532 KB Output is correct
6 Correct 1033 ms 78492 KB Output is correct
7 Correct 981 ms 72396 KB Output is correct
8 Correct 221 ms 20172 KB Output is correct