Cod sursa(job #2776975)
Utilizator | Data | 21 septembrie 2021 18:52:33 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bool c[2000001];
int main()
{
c[0] = c[1] = 1;
for(int i = 2; i <= 1414; ++i)
if(c[i] == 0)
for(int j = 2; i * j <= 2000000; ++j)
c[i * j] = 1;
int n;
int cnt=0;
fin >> n;
for(int i = 1; i <= n; ++i)
{
if(c[i] == 0)
cnt++;
}
fout << cnt;
return 0;
}