Pagini recente » Cod sursa (job #396454) | Cod sursa (job #1802193) | Cod sursa (job #625322) | Cod sursa (job #1693093) | Cod sursa (job #1416270)
# include <cstdio>
using namespace std;
# define N 100000
char p[N];
int main()
{int i,j,n,nr=1;
FILE *f=fopen("ciur.in","r"),*g=fopen("ciur.out","w");
fscanf(f,"%d",&n);
for (i = 1; ((i * i) << 1) + (i << 1) <= n; i += 1) {
if (p[i] == 0) {
for (j = ((i * i) << 1) + (i << 1); (j << 1) + 1 <= n; j += (i << 1) + 1) {
p[j] = 1;
}
}
}
for (i=1; 2 * i + 1 <= n; ++i)
if (p[i] == 0) nr++;
return nr;
fprintf(g,"%d",nr);
}