답안 #856112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856112 2023-10-02T16:51:29 Z vjudge1 Savrsen (COCI17_savrsen) C++17
120 / 120
799 ms 78932 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second
int mod = 998244353;

int inf = LLONG_MAX >> 3;

int mult(int x, int y) {
    return (x%mod)*(y%mod)%mod;
}

const int N = 1e7+1;
int sum[N];
void solve() {
    int l, r;
    cin >> l >> r;
    int ans = 0;
    F(i, l, r+1) {
        ans += abs(sum[i] - i);
    }
    cout << ans << endl;
}

void setIO() {
    F(i, 1, N) {
        for(int j = i*2; j < N; j += i) {
            sum[j] += i;
        }
    }
    ios::sync_with_stdio(0); cin.tie(0);
    #ifdef Local
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
}
signed main() {
    setIO();
    int t = 1;
    //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 780 ms 78688 KB Output is correct
2 Correct 777 ms 78684 KB Output is correct
3 Correct 764 ms 78932 KB Output is correct
4 Correct 728 ms 78680 KB Output is correct
5 Correct 782 ms 78928 KB Output is correct
6 Correct 799 ms 78696 KB Output is correct
7 Correct 746 ms 78680 KB Output is correct
8 Correct 733 ms 78684 KB Output is correct