#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int a, b;
cin>> a >> b;
int ans = 0;
vector<int>sdiv(b+1, 1);
sdiv[1] = 0;
for (int i = 2; i <= b; ++i){
for (int j = 2*i; j <= b; j += i){
sdiv[j] += i;
}
}
for (int i = a; i <= b; ++i) ans += abs(i- sdiv[i]);
cout<< ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
2 ms |
1116 KB |
Output is correct |
4 |
Correct |
755 ms |
78700 KB |
Output is correct |
5 |
Correct |
756 ms |
78936 KB |
Output is correct |
6 |
Correct |
766 ms |
78704 KB |
Output is correct |
7 |
Correct |
678 ms |
72540 KB |
Output is correct |
8 |
Correct |
112 ms |
20312 KB |
Output is correct |