Submission #1055380

# Submission time Handle Problem Language Result Execution time Memory
1055380 2024-08-12T18:31:12 Z fryingduc Savrsen (COCI17_savrsen) C++17
120 / 120
474 ms 78712 KB
/* #pragma GCC optimize("Ofast,unroll-loops") */
#include "bits/stdc++.h"
using namespace std;

#ifdef duc_debug
#include "bits/debug.h"
#else 
#define debug(...)     
#endif

/* #define int long long */

const int mod = 1e7+7;
long long s[mod], b, a;
void sieve(){
    s[1] = 1;
    for(int i = 2; i <= 1e7; i++){
        s[i]++;
        for(int j = i * 2; j <= 1e7; j += i){
            s[j] += i;
        }
        s[i] = abs(i - s[i]);
    }
    for(int i = 1; i <= 1e7; i++) s[i] += s[i-1];
}
void solve(){
    cin >> a >> b;
    cout << s[b] - s[a-1] << '\n';

     debug(1000 * clock() / CLOCKS_PER_SEC);
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    sieve();

    int test = 1;
    /* cin >> test; */
    for(int i = 1; i <= test; i++){
        /* cout << "Case " << "#" << i << ": "; */
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 474 ms 78684 KB Output is correct
2 Correct 463 ms 78712 KB Output is correct
3 Correct 458 ms 78708 KB Output is correct
4 Correct 460 ms 78680 KB Output is correct
5 Correct 453 ms 78680 KB Output is correct
6 Correct 454 ms 78680 KB Output is correct
7 Correct 448 ms 78708 KB Output is correct
8 Correct 460 ms 78704 KB Output is correct