Cod sursa(job #2483690)
Utilizator | Data | 30 octombrie 2019 09:19:54 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int n;
bool v[2000001];
int i,j;
int s;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
v[0]=v[1]=false;
for(i=2;i<=n/2;i++)
{
if(v[i]==false)
for(j=2*i;j<=n;j+=i)v[j]=true;
}
for(j=2;j<=n;j++)
{
if(v[j]==false)s++;
}
g<<s;
}