Cod sursa(job #2353001)
| Utilizator | Data | 23 februarie 2019 19:51:36 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
#include <iostream>
#define nmax 2000005
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, c[nmax], sol;
void eratostene(){
fin >> n;
for(int i = 2; i <= n; ++i)
c[i] = 1;
for(int i = 2; i <= n; ++i)
if(c[i] == 1){
sol++;
for(int j = 2; j * i <= n; j++)
c[i * j] = 0;
}
fout << sol;
}
int main(){
eratostene();
fin.close();
fout.close();
return 0;
}
