Cod sursa(job #1976730)

Utilizator teolegotechnicteolegotechnic teolegotechnic Data 4 mai 2017 08:55:02
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.42 kb
#include <fstream>
#include<cmath>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int main()
{
    int n,i,j,jeep=0,skoda[1000];
    in>>n;
    for(i=2;i<=n;i++)
    {
        skoda[i]=1;
    }
    for(i=2;i<=n;i++)
    {
        if(skoda[i]==1)
            jeep++;
        for(j=i*2;j<=n;j+=i)
        {
            skoda[j]=0;
        }
    }
    out<<jeep;
    return 0;
}