Cod sursa(job #2176972)
Utilizator | Data | 18 martie 2018 11:59:15 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
int ct, n, i, j;
bitset <2010000>w;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f >> n;
for(i = 2;i <= n;i++)
if(w[i] == false)
{
ct++;
for(j = i + i;j <= n;j = j + i)
w[j] = true;
}
g << ct;
return 0;
}