Cod sursa(job #730885)
| Utilizator | Data | 7 aprilie 2012 00:24:34 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <stdio.h>
using namespace std;
const int MAX = 2000050;
bool v[MAX]; int n, contor = 1;
int main()
{
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &n); fclose(stdin);
for(int i = 3; i <= n; i += 2)
if(!v[i])
{
contor++;
for(int j = 2; i * j <= n; j++)
v[i * j] = true;
}
printf("%d", contor); fclose(stdout);
return 0;
}
