Pagini recente » Cod sursa (job #23504) | Cod sursa (job #1097492) | Cod sursa (job #952455) | Cod sursa (job #1463517) | Cod sursa (job #2781465)
#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;
for( int i = 3; i * i <= n; i += 2 )
if( !( ciur[ i >> 3 ] & ( 1 << ( ( i >> 1 ) & 7 ) ) ) )
for( int j = i * i; j <= n; j += i + i )
ciur[ j >> 3 ] |= 1 << ( ( j >> 1 ) & 7 );
for( int i = 3; i <= n; i += 2 )
if( !( ciur[ i >> 3 ] & ( 1 << ( ( i >> 1 ) & 7 ) ) ) )
++no;
FILE *fout = fopen( "ciur.out", "w" );
fprintf( fout, "%d\n", no );
fclose( fout );
return 0;
}