mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 05:18:49 +00:00
P2158 [SDOI2008]仪仗队
R45991218
This commit is contained in:
parent
7fe35ab4bb
commit
2a50080840
23
Luogu/problem/P2158/P2158.cpp
Normal file
23
Luogu/problem/P2158/P2158.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user