Pagini recente » Cod sursa (job #2566762) | Cod sursa (job #1987437) | Cod sursa (job #3162054) | Cod sursa (job #2895267) | Cod sursa (job #3204462)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int v[1000001];
void ciur (int n) {
for (int i = 3; i <= n; i += 2) {
if (v[i / 2 + 1] == 0){
int j = 2;
while (i * j <= n) {
if (i * j % 2 == 1) {
v[(i * j) / 2 + 1] = 1;
}
++j;
}
}
}
}
int main() {
int n;
fin >> n;
ciur(n);
int s = 0;
for(int i = 1; i <= n / 2 + 1; ++i) {
if (v[i] == 0) {
++s;
}
}
if (n == 2) {
fout << 1;
} else {
fout << s - 1;
}
return 0;
}