Submission #603490

# Submission time Handle Problem Language Result Execution time Memory
603490 2022-07-24T07:35:32 Z hieupham1103 Savrsen (COCI17_savrsen) C++17
15 / 120
59 ms 26224 KB
#include<bits/stdc++.h>
#define ii pair <int,int>
#define fi first
#define se second
#define int long long
using namespace std;

const int maxN = 1e5 + 10;

int divSum[maxN + 1];
vector <int> listDiv[maxN + 1];

void Eras(){
    for (int i = 2; i < maxN; i++){
        divSum[i] += 1;
        listDiv[i].push_back(1);
    }
    for (int i = 2; i * i <= maxN; i++){
        for (int j = 2; i * j <= maxN; j++){
            divSum[i * j] += i;
            listDiv[i * j].push_back(i);
        }
    }

}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    Eras();
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++){
        // cout << divSum[i] << ' ';
        ans += abs(i - divSum[i]);
    }

    // for (int i = 1; i <= 100; i++){
    //     cout << i << ": " << abs(i - divSum[i]) << " " << divSum[i] << endl;
    //     for (auto j: listDiv[i]){
    //         cout << j << " ";
    //     }
    //     cout << endl;
    // }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 45 ms 12984 KB Output is correct
2 Incorrect 43 ms 12984 KB Output isn't correct
3 Incorrect 44 ms 12964 KB Output isn't correct
4 Runtime error 59 ms 26224 KB Execution killed with signal 11
5 Runtime error 55 ms 26164 KB Execution killed with signal 11
6 Runtime error 48 ms 26152 KB Execution killed with signal 11
7 Runtime error 58 ms 26144 KB Execution killed with signal 11
8 Runtime error 48 ms 26140 KB Execution killed with signal 11