#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
vector<int> A(10000001, 0);
for (int i = 0; i < 10000001; i++) {
A[i] = i;
}
for (int i = 2; i * i < 10000001; i++) {
for (int j = i * i; j < 10000001; j += i) {
if (j == i * i) {
A[j] = A[j] - i;
}
else {
A[j] = A[j] - (i + (j / i));
}
}
}
int n, m; cin >> n >> m; int sum = 0;
for (int i = n; i <= m; i++) {
if (i != 1) {
A[i] -= 1;
}
// cout << abs(A[i]) << " ";
sum += abs(A[i]);
}
cout << sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |