#include<bits/stdc++.h>
#define ii pair <int,int>
#define fi first
#define se second
#define int long long
using namespace std;
const int maxN = 1e7 + 10;
int divSum[maxN + 1];
// vector <int> listDiv[maxN + 1];
void Eras(){
for (int i = 2; i < maxN; i++){
divSum[i] += 1;
// listDiv[i].push_back(1);
}
for (int i = 2; i * i <= maxN; i++){
for (int j = 2; i * j <= maxN; j++){
divSum[i * j] += i;
// listDiv[i * j].push_back(i);
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Eras();
int a, b;
cin >> a >> b;
int ans = 0;
for (int i = a; i <= b; i++){
// cout << divSum[i] << ' ';
ans += abs(i - divSum[i]);
}
// for (int i = 1; i <= 100; i++){
// cout << i << ": " << abs(i - divSum[i]) << " " << divSum[i] << endl;
// for (auto j: listDiv[i]){
// cout << j << " ";
// }
// cout << endl;
// }
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
600 ms |
78576 KB |
Output is correct |
2 |
Correct |
596 ms |
78572 KB |
Output is correct |
3 |
Incorrect |
597 ms |
78540 KB |
Output isn't correct |
4 |
Incorrect |
709 ms |
78580 KB |
Output isn't correct |
5 |
Incorrect |
595 ms |
78580 KB |
Output isn't correct |
6 |
Incorrect |
638 ms |
78576 KB |
Output isn't correct |
7 |
Incorrect |
605 ms |
78572 KB |
Output isn't correct |
8 |
Incorrect |
621 ms |
78576 KB |
Output isn't correct |