0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 23:28:48 +00:00
OI-codes/AcWing/868/868.cpp

22 lines
425 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, p, primes[1000005];
bool not_prime[1000005];
int main() {
cin >> n;
for (int i = 2; i <= n; i++) {
if (!not_prime[i]) {
primes[p++] = i;
}
for (int j = 0; primes[j] * i <= n; j++) {
not_prime[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
cout << p << endl;
return 0;
}