Cod sursa(job #1623179)

Utilizator AdrianaMAdriana Moisil AdrianaM Data 1 martie 2016 17:42:57
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <fstream>
#include <vector>
#include <stack>
#define INF 0x3f3f3f3f
using namespace std;

ifstream is("ciur.in");
ofstream os("ciur.out");

using VI = vector<int>;
using VVI = vector<VI>;

int n, m;
VI c;

int main()
{
    is >> n;
    m = 1;
    c = VI(n + 1);
    for ( int i = 3; i <= n; i += 2 )
        if ( !c[i] )
        {
            ++m;
            for ( int j = 2 * i; j <= n; j += i )
                c[j] = 1;
        }
    os << m;
    is.close();
    os.close();
    return 0;
}