//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
const int MAXN = 1E7 + 5;
i64 res[MAXN];
void precalc() {
for(int i = 1; i < MAXN; i++) {
for(int j = i; j < MAXN; j += i) {
res[j] += i;
}
}
}
#define ONLINE_JUDGE
void solve() {
int a, b;
cin >> a >> b;
i64 ans = 0;
for(int i = a; i <= b; i++)
ans += abs(res[i] - 2 * i);
cout << ans;
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
precalc();
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
793 ms |
78684 KB |
Output is correct |
2 |
Correct |
777 ms |
78688 KB |
Output is correct |
3 |
Correct |
805 ms |
78680 KB |
Output is correct |
4 |
Correct |
812 ms |
78680 KB |
Output is correct |
5 |
Correct |
805 ms |
78684 KB |
Output is correct |
6 |
Correct |
803 ms |
78684 KB |
Output is correct |
7 |
Correct |
773 ms |
78696 KB |
Output is correct |
8 |
Correct |
779 ms |
78684 KB |
Output is correct |