Pagini recente » Cod sursa (job #78846) | Rating Ostepoc Alex (OstepocAlex) | Statistici ioana ghita (richforthegun) | Clasament dupa rating | Cod sursa (job #790717)
Cod sursa(job #790717)
#include <stdio.h>
#include <bitset>
using namespace std;
bitset<2000006> b;
void sieve(){
b.reset();
b.flip();
b[0]=0;
b[1]=0;
for(int i=2;i<b.size();i++){
if(b[i]){
for(int j=i*i;j<b.size();j+=i)
{ b[j]=0;
}
}
}
}
int main(){
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
int n,nr=0;
scanf("%d",&n);
sieve();
for(int i=2;i<=n;i++){
if(b[i])
nr++;
}
printf("%d",nr);
return 0;
}