Cod sursa(job #2227841)
Utilizator | Data | 1 august 2018 23:27:49 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main()
{
ifstream in("ciur.in");
ofstream out("ciur.out");
vector<bool> p;
int n;
in >> n;
p.resize(n, false);
int total = 1;
for ( int i = 3; i < n; i += 2 )
if (!p[i])
{
++total;
for ( int j = 2; i*j < n; j++ )
{
p[i*j] = true;
}
}
out << total << "\n";
return 0;
}