Pagini recente » Cod sursa (job #929789) | Cod sursa (job #2538952) | Cod sursa (job #496223) | Cod sursa (job #2311928) | Cod sursa (job #936071)
Cod sursa(job #936071)
#include<cstdio>
#define CLOSE fclose(in); fclose(out); return 0;
using namespace std;
FILE *in,*out;
const int LIM = 2000100;
int v[LIM+10];
void ciur(){
for(register int i = 2; i<=LIM; ++i)
if(!v[i])
for(register long long j = (long long)i*i; j<=LIM; j+=i)
v[j]=1;
}
inline int negatie (int a){
return a==0 ? 1 : 0;
}
void sume(){
for(register int i =2; i<=LIM; ++i)
v[i]=v[i-1]+negatie(v[i]);
}
int main(){
in=fopen("ciur.in","r");
out=fopen("ciur.out","w");
ciur();
sume();
int X;
fscanf(in,"%d",&X);
fprintf(out,"%d\n",v[X]);
CLOSE
}