Cod sursa(job #2372711)
Utilizator | Data | 7 martie 2019 10:42:43 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int v[10000000],ok;
void eratostene(int n)
{
int i,j;
v[0]=1;
v[1]=1;
for(i=2;i<=n;i++)
{
if(v[i]==0)
{ok++;
for(j=i+i;j<=n;j+=i)
v[j]=1;
}
}
}
int main()
{
int n;
in>>n;
eratostene(n);
out<<ok;
}