Cod sursa(job #1509037)

Utilizator antohieantohie andrei antohie Data 23 octombrie 2015 14:02:28
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
bool a[2000001];

int main ()
{
    ifstream f("ciur.in");
    ofstream g("ciur.out");

    int n;
    f>>n;

    int i,j;
    for(i=2; i<=n; i++)
          if( a[i]==0 )
        for(j=i+i; j<=n; j+=i)
                a[j]=1;
    int    k=0;
    for(i=2; i<=n; i++)
        if(a[i]==0)
            k++;
    g<<k;



}