Cod sursa(job #2461839)

Utilizator VasAlexVasiluta Alex VasAlex Data 26 septembrie 2019 11:13:40
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("ciur.in");
ofstream g("ciur.out");
int n, m, i, j, t = 1;
bool ciur[2000002];
int main()
{
    f >> n;
    for(i = 4; i <= n; i += 2)
        ciur[i] = 1;
    for(i = 3; i <= n; i += 2)
    {
        if(!ciur[i])
        {
            t++;
            for(j = i * 2; j <= n; j += i)
                ciur[j] = 1;
        }
    }
    g << t;
    return 0;
}