Pagini recente » Cod sursa (job #2934844) | Cod sursa (job #2124754) | Cod sursa (job #1308748) | Cod sursa (job #1587719) | Cod sursa (job #2781470)
#include <stdio.h>
unsigned char ciur[ ( 1 << 17 ) ];
int main()
{
int n;
FILE *fin = fopen( "ciur.in", "r" );
fscanf( fin, "%d", &n );
fclose( fin );
int no = 1, i;
for( i = 3; i * i <= n; i += 2 )
if( !( ciur[ i >> 4 ] & ( 1 << ( ( i >> 1 ) & 7 ) ) ) ) {
++no;
for( int j = i * i; j <= n; j += i + i )
ciur[ j >> 4 ] |= 1 << ( ( j >> 1 ) & 7 );
}
for( ; i <= n; i += 2 )
if( !( ciur[ i >> 4 ] & ( 1 << ( ( i >> 1 ) & 7 ) ) ) )
++no;
FILE *fout = fopen( "ciur.out", "w" );
fprintf( fout, "%d\n", no );
fclose( fout );
return 0;
}