Lang:G++
Edit1234567891011121314151617181920212223242526272829#include <bits/stdc++.h>#define LL long long#define INF 0x3f3f3f3f#define eps 1e-8#define MAXN 1000005using namespace std;bool vis[MAXN];int main(){#ifndef ONLINE_JUDGE//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);#endif // ONLINE_JUDGEint n;scanf("%d", &n);vis[0] = vis[1] = true;int cnt = 0;for(int i = 2; i <= n; ++i){if(vis[i]) continue;++cnt;if(i > n / i) continue;for(int j = i * i; j <= n; j += i){vis[j] = true;}}printf("%d\n", cnt);}