#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
vector<long long> sum(b+1);
for (int i = 2; i <= b; i++) {
for (int j = i+i; j <= b; j += i) sum[j] += i;
sum[i]++;
}
long long ans = 0;
for (int i = a; i <= b; i++) ans += abs(i-sum[i]);
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
1104 KB |
Output is correct |
4 |
Correct |
499 ms |
78524 KB |
Output is correct |
5 |
Correct |
523 ms |
78708 KB |
Output is correct |
6 |
Correct |
497 ms |
78672 KB |
Output is correct |
7 |
Correct |
449 ms |
72444 KB |
Output is correct |
8 |
Correct |
49 ms |
20304 KB |
Output is correct |