#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = 1e9 + 7;
int divs[10000001] = {};
signed main () {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for (int i = 1; i <= 1e7; i++) {
for (int j = 2 * i; j <= 1e7; j += i) {
divs[j] += i;
}
}
int a, b;
cin >> a >> b;
int sum = 0;
for (int i = a; i <= b; i++) sum += abs(i - divs[i]);
cout << sum << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1177 ms |
78656 KB |
Output is correct |
2 |
Correct |
1147 ms |
78576 KB |
Output is correct |
3 |
Correct |
1189 ms |
78668 KB |
Output is correct |
4 |
Correct |
1154 ms |
78576 KB |
Output is correct |
5 |
Correct |
1186 ms |
78576 KB |
Output is correct |
6 |
Correct |
1150 ms |
78664 KB |
Output is correct |
7 |
Correct |
1158 ms |
78592 KB |
Output is correct |
8 |
Correct |
1162 ms |
78580 KB |
Output is correct |