Pagini recente » Cod sursa (job #2541300) | Cod sursa (job #1201111) | Cod sursa (job #261970) | Cod sursa (job #1223059) | Cod sursa (job #2638583)
#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) {
for (int j = i + i; j <= n; j += i) {
notPrime[j] = 1;
}
}
for (int i = 2; i <= n; ++i) {
if (!notPrime[i]) {
answer += 1;
}
}
fout << answer;
return 0;
}