0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 21:16:27 +00:00
Baoshuo Ren 2021-08-03 21:30:46 +08:00 committed by Baoshuo Ren
parent 03630f4f07
commit b09f55411e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
AcWing/868/868.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
bool isprime[1000005];
int n, ans;
int main() {
cin >> n;
for (int i = 0; i <= n; i++) {
isprime[i] = true;
}
isprime[0] = isprime[1] = false;
for (int i = 2; i <= n; i++) {
if (isprime[i] && 1ll * i * i <= n) {
for (int j = i * i; j <= n; j += i) {
isprime[j] = false;
}
}
}
for (int i = 1; i <= n; i++) {
ans += isprime[i];
}
cout << ans;
return 0;
}