#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
const int N = 1e7 + 1;
long long d[N];
int a, b;
long long c;
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> a >> b;
for (int i = 1; i <= b; ++i) {
for (int j = max(2 * i, i * (a / i)); j <= b; j += i) {
d[j] += i;
}
}
for (int i = a; i <= b; ++i) {
c += abs(i - d[i]);
}
cout << c;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
2692 KB |
Output is correct |
4 |
Correct |
49 ms |
27228 KB |
Output is correct |
5 |
Correct |
746 ms |
74424 KB |
Output is correct |
6 |
Correct |
797 ms |
78928 KB |
Output is correct |
7 |
Correct |
738 ms |
74308 KB |
Output is correct |
8 |
Correct |
126 ms |
21084 KB |
Output is correct |