답안 #948953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948953 2024-03-18T17:16:16 Z penguinma Savrsen (COCI17_savrsen) C++17
120 / 120
654 ms 39564 KB
#include <iostream>
#include <vector>
using namespace std;

int abs(int x) { return x > 0 ? x : -x; }

int main() {
    int a, b;
    cin >> a >> b;
    int M = b + 1;
    vector<int> v(M);
    for (int d = 1; d < M; ++d) {
        int dd = d + d;
        while (dd < M) {
            v[dd] += d;
            dd += d;
        }
    }
    long long s = 0;
    for (int i = a; i <= b; ++i)
        s += abs(v[i] - i);
    cout << s << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 646 ms 39564 KB Output is correct
5 Correct 643 ms 39560 KB Output is correct
6 Correct 654 ms 39564 KB Output is correct
7 Correct 582 ms 36484 KB Output is correct
8 Correct 32 ms 10332 KB Output is correct