Cod sursa(job #2176961)
Utilizator | Data | 18 martie 2018 11:53:45 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
int ct, n, i, j;
bool w[2010000];
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;
}