Cod sursa(job #3002819)
Utilizator | Data | 15 martie 2023 11:19:55 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int v[2000001];
int main()
{int n, cont=0;
fin>>n;
v[0]=1;
v[1]=1;
for(int i=2; i*i<=n; i++)
{
if(!v[i])
for(int j=2; j<=n/i; j++)
v[i*j]=1;
}
for(int i=2; i<=n; i++)
if(!v[i])
cont++;
fout<<cont;
return 0;
}