Cod sursa(job #2965421)

Utilizator xeodorAvram Petru-Teodor xeodor Data 15 ianuarie 2023 12:16:05
Problema Ciurul lui Eratosthenes Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.36 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
int n,i,v[2000000],h,j;
int main()
{
    fin>>n;
    for(i=2;i<=n/2;i++)
        if(v[i]==0)
            for(j=2;i*j<=n;j++)
                v[i*j]=1;
    for(i=2;i<=n;i++)
        if(v[i]==0)
            h++;
    fout<<h;
    return 0;
}