답안 #109146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109146 2019-05-04T18:24:17 Z bibabas Savrsen (COCI17_savrsen) C++14
120 / 120
1853 ms 39568 KB
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int INF = (int)2e9;

using namespace std;

template <class T>
istream& operator >>(istream &in, vector<T> &arr) {
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
};

int sum[(int)1e7 + 1];

void solve() {
    sum[1] = 0;
    int a, b; cin >> a >> b;
    ll ans = 0;
    for (int i = 1; i <= (int)1e7; ++i){
        if (a <= i && i <= b)
            ans += abs(sum[i] - i);
        for (int j = 2 * i; j <= (int)1e7; j += i){
            sum[j] += i;
        }
    }
    cout << ans;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1666 ms 39544 KB Output is correct
2 Correct 1810 ms 39416 KB Output is correct
3 Correct 1816 ms 39508 KB Output is correct
4 Correct 1812 ms 39544 KB Output is correct
5 Correct 1660 ms 39544 KB Output is correct
6 Correct 1613 ms 39544 KB Output is correct
7 Correct 1853 ms 39544 KB Output is correct
8 Correct 1810 ms 39568 KB Output is correct