//Dedicated to my love, ivaziva
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';
int sum[10000005];
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
int a, b;
cin >> a >> b;
for (int i = 2; i < 10000001; i++) {
for (int j = i + i; j < 10000001; j += i) {
sum[j] += i;
}
}
int ans = 0;
for (int i = a; i <= b; i++) {
if (i == 1) {
ans += abs(i - sum[i]);
} else {
ans += abs(i - sum[i] - 1);
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
595 ms |
78932 KB |
Output is correct |
2 |
Correct |
567 ms |
78676 KB |
Output is correct |
3 |
Correct |
552 ms |
78592 KB |
Output is correct |
4 |
Correct |
563 ms |
78704 KB |
Output is correct |
5 |
Correct |
589 ms |
78676 KB |
Output is correct |
6 |
Correct |
559 ms |
78696 KB |
Output is correct |
7 |
Correct |
593 ms |
78708 KB |
Output is correct |
8 |
Correct |
555 ms |
78676 KB |
Output is correct |