Pagini recente » Cod sursa (job #2574788) | Cod sursa (job #2756635) | Diferente pentru problema/viteza2 intre reviziile 2 si 20 | Profil AlloysNokitoAM | Cod sursa (job #2638585)
#include <bits/stdc++.h>
using namespace std;
bool notPrime[2000002];
int main() {
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, answer = 0;
fin >> n;
notPrime[0] = notPrime[1] = 1;
for (int i = 2; i <= n; ++i) {
if (!notPrime[i])
{
answer += 1;
for (int j = i + i; j <= n; j += i) {
notPrime[j] = 1;
}
}
}
fout << answer;
return 0;
}