Cod sursa(job #825189)
Utilizator | Data | 27 noiembrie 2012 20:06:58 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include<fstream>
#define max 2000100
using namespace std;
ifstream f ("ciur.in");
ofstream g ("ciur.out");
int n,i,j,contor;
bool v[max];
int main(){
f>>n;
for (i=2; i<=n; i++)
if(!v[i])
{contor ++;
for(j=i; j<=n; j+= i)
v[j] = true;}
g<<contor;
return 0;
}