Cod sursa(job #2232401)
Utilizator | Data | 18 august 2018 22:16:20 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, nr;
bool t[2000002];
int main()
{
fin >> n;
int rad=sqrt(n);
for(int i = 2; i <= n; ++i)
if( !t[i])
{
int j = 2;
++nr;
while (i*j <= n)
{
t[i*j] = 1;
++j;
}
}
fout << nr;
return 0;
}