#include <bits/stdc++.h>
using namespace std;
long long imperf[10000001];
int A, B;
int main(){
cin >> A >> B;
for(int i=2; i*i<=B; i++){
for(int j=i; j*i<=B; j++){
if(i==j){
imperf[i*j] += i;
}
else{
imperf[i*j] += i+j;
}
}
}
imperf[1] = 1;
/*
for(int i=0; i<=B; i++){
cout << " " << abs(imperf[i]+1-i);
}
cout << endl;
*/
long long sum = 0;
for(int i=A; i<=B; i++){
sum += abs(imperf[i]+1-i);
}
cout << sum << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
1100 KB |
Output is correct |
4 |
Correct |
910 ms |
78552 KB |
Output is correct |
5 |
Correct |
919 ms |
78544 KB |
Output is correct |
6 |
Correct |
895 ms |
78548 KB |
Output is correct |
7 |
Correct |
843 ms |
72392 KB |
Output is correct |
8 |
Correct |
180 ms |
20176 KB |
Output is correct |