Cod sursa(job #1019518)
Utilizator | Data | 31 octombrie 2013 13:06:20 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<fstream>
#define nmax 2000001
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int n;
char p[nmax];
int main()
{ f>>n;
int i, j, nr = 0;
for (i = 2; i <= n; ++i)
if (p[i] == 0)
{
nr++;
for (j = i + i; j <= n; j += i) p[j] = 1;
}
g<<nr<<"\n";
g.close(); return 0;
}