답안 #1091885

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091885 2024-09-22T13:11:37 Z plagia Savrsen (COCI17_savrsen) C++14
45 / 120
21 ms 8468 KB
#include <cstdlib>
#include <iostream>

const int MM = 1e6 + 10;
int tab[MM]{};

void fill_tab() {
    for (int i = 1; i < MM; i++) {
        tab[i] = 0;  // Initialize all values to zero
    }

    for (int i = 1; i < MM; i++) {  // i is a potential divisor
        for (int j = 2 * i; j < MM; j += i) {  // add i to all multiples of i, excluding itself
            tab[j] += i;
        }
    }
}

int calculate_imperfection(const int &n) {
    return std::abs(n - tab[n]);
}

int main() {
    std::ios_base::sync_with_stdio(0);

    fill_tab();

    int a, b;
    std::cin >> a >> b;
    
    unsigned long long sum = 0;
    for (int i = a; i <= b; i++) {
        sum += calculate_imperfection(i);
    }

    std::cout << sum << std::endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 4188 KB Output is correct
2 Correct 19 ms 4364 KB Output is correct
3 Correct 21 ms 4444 KB Output is correct
4 Runtime error 17 ms 8464 KB Execution killed with signal 11
5 Runtime error 19 ms 8284 KB Execution killed with signal 11
6 Runtime error 19 ms 8284 KB Execution killed with signal 11
7 Runtime error 17 ms 8468 KB Execution killed with signal 11
8 Runtime error 18 ms 8276 KB Execution killed with signal 11