답안 #75093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75093 2018-09-08T09:48:21 Z charlies_moo Savrsen (COCI17_savrsen) C++17
60 / 120
2305 ms 79164 KB
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int p[4000];
    int pc = 0;
    for (int i = 2; i < 4000; i++) {
        bool f = true;
        for (int j = 0; j < pc; j++) {
            if (i % p[j] == 0) {
                f = false;
                break;
            }
        }

        if (f) {
            p[pc++] = i;
        }
    }
    
    int a, b;
    cin >> a >> b;

    long long f[b+1];
    f[1] = 1;
    for (int i = 2; i <= b; i++) {
        int q = 0;
        for (int j = 0; j < pc; j++) {
            if (i % p[j] == 0) {
                q = p[j];
                break;
            }
        }
        
        if (q) {
            int t = q, s = 1;
            while (i % t == 0) {
                s += t;
                t *= q;
            }
            t /= q;
            f[i] = s * f[i/t];
        } else {
            f[i] = i + 1;
        }
    }
    
    long long ans = 0;
    for (int i = a; i <= b; i++) {
        ans += abs(f[i] - i - i);
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 29 ms 1224 KB Output is correct
4 Correct 2227 ms 78868 KB Output is correct
5 Incorrect 2226 ms 79164 KB Output isn't correct
6 Incorrect 2305 ms 79164 KB Output isn't correct
7 Incorrect 2064 ms 79164 KB Output isn't correct
8 Incorrect 571 ms 79164 KB Output isn't correct