#include<bits/stdc++.h>
using namespace std;
const int DIM = 1e7 + 5;
int A, B, f[DIM];
long long ans = 0;
int main(){
cin >> A >> B;
for( int i = 1; i <= B; i++ ){
f[i] -= i;
for( int j = i + i; j <= B; j += i )
f[j] += i;
}
for( int i = A; i <= B; i++ )
ans += max( f[i], -f[i] );
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
760 KB |
Output is correct |
4 |
Correct |
1438 ms |
39496 KB |
Output is correct |
5 |
Correct |
1450 ms |
39500 KB |
Output is correct |
6 |
Correct |
1384 ms |
39496 KB |
Output is correct |
7 |
Correct |
1213 ms |
36472 KB |
Output is correct |
8 |
Correct |
145 ms |
10360 KB |
Output is correct |