Cod sursa(job #869554)

Utilizator Lorand0997Lorand Lorand0997 Data 1 februarie 2013 19:37:34
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.31 kb
#include <iostream>
#include <fstream>
using namespace std;
bool ciur[2000005];
int main()
{
    ifstream f("ciur.in");
    ofstream g("ciur.out");
    int n,m,l,j;
    f>>n;
    m=0;
    for(l=2;l<=n;l++)
    if(!ciur[l]){
    m++;
    for(j=l+l;j<=n;j+=l)
    ciur [j]=1;}
    g<<m;
    return 0;
}