답안 #646062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646062 2022-09-28T14:38:01 Z mr_robot_545 Savrsen (COCI17_savrsen) C++17
120 / 120
1042 ms 39440 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 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 947 ms 39440 KB Output is correct
5 Correct 1042 ms 39432 KB Output is correct
6 Correct 989 ms 39428 KB Output is correct
7 Correct 920 ms 36356 KB Output is correct
8 Correct 143 ms 10248 KB Output is correct