Cod sursa(job #1232008)
Utilizator | Data | 21 septembrie 2014 21:10:33 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
int n;
fin >> n;
bool t[2000005];
for(int i = 2; i <= n/2; i++ ){
if( t[i] == 0 )
{
int j = i + i;
while(j <= n)
{
t[j] = 1;
j = j + i;
}
}
}
int total = 0;
for(int i = 2; i <= n; i++)
if( t[i] == 0 ) total++;
fout << total;
}