Cod sursa(job #2311485)
| Utilizator | Data | 3 ianuarie 2019 12:21:33 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fi ("ciur.in");
ofstream fo ("ciur.out");
long long n,m=1,s;
bool v[2000001];
int main()
{
fi >> n;
v[0] = 1;
v[1] = 1;
for (int i = 1 ; i <= 2000000 ; ++i)
{
if (v[i] == 0)
for (int j = i+i ; j <= 2000000 ; j += i)
v[j] = 1;
}
for (int i = 1 ; i <= n ; ++i)
{
if (v[m] == 0)
++s;
++m;
}
fo << s;
return 0;
}
