#include <bits/stdc++.h>
#define N 10000005
using namespace std;
int arr[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int a,b;
cin >> a >> b;
long long sum = 0;
for(int i=1;i<N;i++){
for(int j=i+i;j<N;j+=i){
arr[j] -= i;
}
arr[i]+=i;
}
for(int i=a;i<=b;i++){
sum += abs(arr[i]);
}
cout << sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1309 ms |
39536 KB |
Output is correct |
2 |
Correct |
1294 ms |
39532 KB |
Output is correct |
3 |
Correct |
1335 ms |
39660 KB |
Output is correct |
4 |
Correct |
1310 ms |
39536 KB |
Output is correct |
5 |
Correct |
1321 ms |
39536 KB |
Output is correct |
6 |
Correct |
1325 ms |
39532 KB |
Output is correct |
7 |
Correct |
1321 ms |
39536 KB |
Output is correct |
8 |
Correct |
1318 ms |
39660 KB |
Output is correct |