Cod sursa(job #2415788)
Utilizator | Data | 26 aprilie 2019 15:15:57 | |
---|---|---|---|
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;
bool ciur[2000005];
int main()
{
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, cnt = 0;
fin >> n;
for(int i = 2; i <= n; ++i){
if(!ciur[i]){
cnt++;
for(long long j = i * i * 1LL; j <= n; j += i)
ciur[j] = 1;
}
}
fout << cnt;
return 0;
}