Cod sursa(job #2120075)

Utilizator Andrei.GheorgheAndrei Gheorghe Andrei.Gheorghe Data 1 februarie 2018 21:14:00
Problema Ciurul lui Eratosthenes Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.37 kb
#include<fstream>
using namespace std;
bool v[1900002];
int main()
{
    ifstream cin("ciur.in");
    ofstream cout("ciur.out");
    int n,i,j;
    int nr=0;
    cin>>n;
    for(i=2;i<=n;i++)
    {
        if(v[i]==0)
            {
                nr++;
        for(j=i+i;j<=n;j=j+i)
        {
            v[j]=1;
        }
            }
    }
    cout<<nr;
}