#include <iostream>
#include <vector>
using namespace std;
int abs(int x) { return x > 0 ? x : -x; }
int main() {
int a, b;
cin >> a >> b;
int M = b + 1;
vector<int> v(M);
for (int d = 1; d < M; ++d) {
int dd = d + d;
while (dd < M) {
v[dd] += d;
dd += d;
}
}
long long s = 0;
for (int i = a; i <= b; ++i)
s += abs(v[i] - i);
cout << s << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
1292 ms |
39420 KB |
Output is correct |
5 |
Correct |
1277 ms |
39416 KB |
Output is correct |
6 |
Correct |
1344 ms |
39388 KB |
Output is correct |
7 |
Correct |
1205 ms |
36344 KB |
Output is correct |
8 |
Correct |
202 ms |
10188 KB |
Output is correct |