Pagini recente » Cod sursa (job #3041094) | Infoarena Monthly 2012, Runda 11 | Cod sursa (job #1435135) | Cod sursa (job #1335912) | Cod sursa (job #1870211)
#include <stdio.h>
#include <bitset>
using namespace std;
#define ll long long unsigned
#define pb push_back
#define mp make_pair
bitset <2000005> ciur;
int sieve(int n){
int i,j;
int ans = 1;
for(i = 4;i <= n;i += 2){
ciur[i] = 1;
}
for(i = 3;i*i <= n;i += 2){
if(ciur[i] == 0){
ans++;
for(j = i*i;j <= n;j += 2*i){
ciur[j] = 1;
}
}
}
for(;i <= n;i += 2){
if(ciur[i] == 0){
ans++;
}
}
return ans;
}
int main(){
int n;
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d",&n);
printf("%d",sieve(n));
return 0;
}