0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 00:05:24 +00:00

P2158 [SDOI2008]仪仗队

R45991218
This commit is contained in:
Baoshuo Ren 2021-02-02 15:38:43 +08:00 committed by Baoshuo Ren
parent 7fe35ab4bb
commit 2a50080840
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,23 @@
#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;
}