#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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
65 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Runtime error |
70 ms |
131072 KB |
Execution killed with signal 9 |
3 |
Runtime error |
85 ms |
131072 KB |
Execution killed with signal 9 |
4 |
Runtime error |
70 ms |
131072 KB |
Execution killed with signal 9 |
5 |
Runtime error |
66 ms |
131072 KB |
Execution killed with signal 9 |
6 |
Runtime error |
62 ms |
131072 KB |
Execution killed with signal 9 |
7 |
Runtime error |
82 ms |
131072 KB |
Execution killed with signal 9 |
8 |
Runtime error |
80 ms |
131072 KB |
Execution killed with signal 9 |