#include<bits/stdc++.h>
using namespace std;
const int N = 1e7 + 1;
int dp[N];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
for(int i = 1; i < N; i++){
for(int j = 2 * i; j < N; j += i){
dp[j] += i;
}
}
int l, r;
cin >> l >> r;
long long ans = 0;
for(int i = l; i <= r; i++){
ans += abs(i - dp[i]);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1516 ms |
39544 KB |
Output is correct |
2 |
Correct |
1635 ms |
39544 KB |
Output is correct |
3 |
Correct |
1772 ms |
39416 KB |
Output is correct |
4 |
Correct |
1554 ms |
39544 KB |
Output is correct |
5 |
Correct |
1598 ms |
39544 KB |
Output is correct |
6 |
Correct |
1618 ms |
39800 KB |
Output is correct |
7 |
Correct |
1629 ms |
39516 KB |
Output is correct |
8 |
Correct |
1568 ms |
39516 KB |
Output is correct |