Cod sursa(job #2640443)
Utilizator | Data | 6 august 2020 14:32:09 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nmax = 2000005;
ll vect[nmax];
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
ll n;
fin >> n;
ll cnt = 0;
for (ll i = 2; i <= n; i++)
{
if(vect[i] == 0)
{ cnt++;
for (ll j = i * i; j <= n; j += i)
vect[j] = 1;
}
}
fout << cnt;
}