0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 18:36:26 +00:00
OI-codes/Luogu/P3912/P3912.cpp

24 lines
465 B
C++
Raw Normal View History

2020-11-02 11:59:20 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
2021-11-19 09:01:13 +00:00
int s = n - 1;
2020-11-02 11:59:20 +00:00
bool prime[100000005];
memset(prime, 0, sizeof(prime));
2021-11-19 09:01:13 +00:00
for (int i = 2; i * i <= n; i++) {
if (!prime[i]) {
for (int j = i * 2; j <= n; j += i) {
if (!prime[j]) {
2020-11-02 11:59:20 +00:00
prime[j] = true;
s--;
}
}
}
}
cout << s << endl;
return 0;
}