#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
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 |
2 ms |
1100 KB |
Output is correct |
4 |
Correct |
1037 ms |
78540 KB |
Output is correct |
5 |
Correct |
1047 ms |
78532 KB |
Output is correct |
6 |
Correct |
1033 ms |
78492 KB |
Output is correct |
7 |
Correct |
981 ms |
72396 KB |
Output is correct |
8 |
Correct |
221 ms |
20172 KB |
Output is correct |