Pagini recente » Cod sursa (job #2255205) | Cod sursa (job #211874) | Cod sursa (job #2837428) | Cod sursa (job #1609018) | Cod sursa (job #2293927)
#include <bits/stdc++.h>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
vector< bool > isPrime(2e6 + 10, true);
int main() {
ios::sync_with_stdio(false); in.tie(0); out.tie(0);
int n; in >> n;
for(int i = 4; i <= n; i += 2) {
isPrime[i] = false;
}
int ans = 1;
for(int i = 3; i <= n; i += 2) {
if(isPrime[i]) {
++ans;
for(int j = i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
out << ans << "\n";
in.close(); out.close();
return 0;
}