Pagini recente » Cod sursa (job #1931525) | Cod sursa (job #721651) | Cod sursa (job #2192203) | Cod sursa (job #2937667) | Cod sursa (job #979646)
Cod sursa(job #979646)
#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
bitset <2000005> b;
int i,k,i1,n;
int main(void)
{
FILE * f;
f=fopen("ciur.in","r");
ofstream g("ciur.out");
fscanf(f,"%d",&n);
k=0;
for (i=0;i<2000004;i++)
b[i]=0;
for (i=2;i<=n;i++)
if (b[i]==0)
{
k++;
for (i1=i*i;i1<=n;i1=i1+i)
b[i1]=1;
}
g<<k<<'\n';
g.close();
return 0;
}