Pagini recente » Cod sursa (job #1477287) | Cod sursa (job #1741003) | Cod sursa (job #1767198) | Cod sursa (job #2508058) | Cod sursa (job #645288)
Cod sursa(job #645288)
#include<cstdio>
#include<cstring>
using namespace std;
#define NMAX 2000001
int ciur( int n ){
int j,i,M=n-1;
char mask[NMAX];
memset( mask, 0, NMAX / sizeof( char ) );
for( i=4; i<=n; i+=2 ){
mask[i] = 1;
--M;
}
for( i=3; i<=n; i+=2 ){
if( mask[i] == 0 ){
for( j=i*i; j<=n; j+=i ){
if( mask[j] == 0 && j % i == 0 ){
mask[j] = 1;
--M;
}
}
}
}
return M;
}
int main(){
int n;
freopen( "ciur.in", "r", stdin );
freopen( "ciur.out", "w", stdout );
scanf( "%d", &n );
printf( "%d", ciur( n ) );
return 0;
}