#include <iostream>
#define DIM 10000010
using namespace std;
int i,j,a,b;
long long sol,d[DIM];
int main (){
for (i=2;i<DIM/2;i++){
for (j=i+i;j<DIM;j+=i)
d[j] += i;
}
cin>>a>>b;
for (i=a;i<=b;i++){
if (i == 1)
sol++;
else sol += max (i-d[i]-1,1+d[i]-i);
}
cout<<sol;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1885 ms |
78664 KB |
Output is correct |
2 |
Correct |
1972 ms |
78628 KB |
Output is correct |
3 |
Correct |
1872 ms |
78628 KB |
Output is correct |
4 |
Correct |
1968 ms |
78660 KB |
Output is correct |
5 |
Correct |
1907 ms |
78624 KB |
Output is correct |
6 |
Correct |
1958 ms |
78628 KB |
Output is correct |
7 |
Correct |
1906 ms |
78636 KB |
Output is correct |
8 |
Correct |
1895 ms |
78632 KB |
Output is correct |