Cod sursa(job #2267930)

Utilizator hax_m8Nicolae Antonio Cristian hax_m8 Data 24 octombrie 2018 12:09:39
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <iostream>

using namespace std;

ifstream fin("ciur.in");
ofstream fout("ciur.out");

int v[1005];

int main()
{
    int n, cnt = 0;
    fin >> n;
    v[0] = 1;
    v[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for(int j = i + i; j <= n; j += i)
        {
            v[j] = 1;
        }
    }
    for (int i = 0; i < n; i++)
        if(!v[i]) cnt++;
    fout << cnt;
    return 0;
}