0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 14:18:48 +00:00
OI-codes/Luogu/problem/P2158/P2158.cpp

23 lines
415 B
C++
Raw Normal View History

2021-02-02 07:38:43 +00:00
#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;
}