Submission #1244823

#TimeUsernameProblemLanguageResultExecution timeMemory
1244823CrabCNHSavrsen (COCI17_savrsen)C++20
120 / 120
918 ms78712 KiB
#include <bits/stdc++.h>

#define pii pair <int, int>
#define fi first
#define se second

using namespace std;

const int N = 1e7 + 5;
const int inf = 1e18 + 7;

long long sub[N];

signed main () {
    ios_base :: sync_with_stdio (0);
    cin.tie (0);
    cout.tie (0);
    #define task "crab"
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= b; i++) {
        for (int j = i + i; j <= b; j += i) {
            sub[j] = sub[j] + i;
        }
    }
    long long ans = 0;
    for (int i = a; i <= b; i ++) {
        ans += abs ((long long)i - sub[i]);
    }
    cout << ans;
}

Compilation message (stderr)

savrsen.cpp:10:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   10 | const int inf = 1e18 + 7;
      |                 ~~~~~^~~
savrsen.cpp: In function 'int main()':
savrsen.cpp:20:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
savrsen.cpp:21:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...