constint N = 1e6 + 10; int pr[N]; bool st[N]; int cnt;
intmain() { int n; cin >> n; for (int i = 2; i <= n; i++) { if (!st[i]) pr[++cnt] = i; // we consider i is a prime num if i wasn't get sieved for (int j = i + i; j <= n; j+=i) // sieves all the multiple nums of i { st[j] = true; } } cout << cnt << endl; return0; }
constint N = 1e6 + 10; int pr[N]; bool st[N]; int cnt;
intmain() { int n; cin >> n; for (int i = 2; i <= n; i++) { if (!st[i]) { pr[++cnt] = i; // we consider i is a prime num if i wasn't get sieved for (int j = i + i; j <= n; j+=i) // sieves all the multiple nums of i when i is a prime num st[j] = true; } } cout << cnt << endl; return0; }