Cod sursa(job #1189228)
| Utilizator | Data | 21 mai 2014 21:12:31 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.34 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); nrp = n - 1;
for (i = 2; i <= n; i++) for (j = 2 * i; j <= n; j += i) nrp -= 1 - P[j], P[j] = 1;
printf("%d", nrp);
return 0;
}