#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int Abs(int x) {
return x > 0 ? x : -x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int a, b;
cin >> a >> b;
vector<ll> dp(b + 1);
for (int i = 1; i <= b; ++i) {
for (int j = i * 2; j <= b; j += i) {
dp[j] += i;
}
}
ll res = 0;
for (int i = a; i <= b; ++i) {
res += Abs(i - dp[i]);
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
1100 KB |
Output is correct |
4 |
Correct |
1188 ms |
78544 KB |
Output is correct |
5 |
Correct |
1097 ms |
78464 KB |
Output is correct |
6 |
Correct |
1158 ms |
78540 KB |
Output is correct |
7 |
Correct |
1006 ms |
72384 KB |
Output is correct |
8 |
Correct |
221 ms |
20172 KB |
Output is correct |