Cod sursa(job #1189226)

Utilizator MarianMMorosac George Marian MarianM Data 21 mai 2014 21:06:41
Problema Ciurul lui Eratosthenes Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>

int n, nrp;	bool P[2000001];

int main(){
	int i, j;

	freopen("ciur.in", "r", stdin);
	freopen("ciur.out", "w", stdout);

	scanf("%d", &n);
	for (i = 2; i <= n; i++) for (j = 2 * i; j <= n; j += i) P[j] = 1;
	for (i = 2; i <= n; i++) if (!P[i]) nrp++;
	printf("%d", nrp);

	return 0;
}