0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 18:12:04 +00:00
OI-codes/Luogu/problem/P2158/P2158.cpp
2021-02-02 15:38:43 +08:00

23 lines
415 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, ans, f[50000];
int main() {
cin >> n;
ans = (n - 1) * (n - 1);
if(!--n) {
cout << 0 << endl;
return 0;
}
for (int i = n; i >= 2; i--) {
f[i] = (n / i) * (n / i);
for (int j = 2 * i; j <= n; j += i) {
f[i] -= f[j];
}
ans -= f[i];
}
cout << ans + 2 << endl;
return 0;
}