Pagini recente » Rating Mataranga Ianis Matei (Angel27) | Rating Birghilescu Alexandru (Arcopie) | Cod sursa (job #1252994) | Clasament lmk_12_vs | Cod sursa (job #3284468)
#include <fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
char v[2000001];
int main()
{
long long n, cnt=0;
in>>n;
for(int i=0; i<n; i++)
v[i]='0';
v[0]=1;
v[1]=1;
int d=2;
while(d*d<=n){
if(v[d]=='0'){
for(int j=2; j<=n/d; j++){
v[j*d]='1';
}
}
d++;
}
for(int i=0; i<n; i++){
if(v[i]=='0')
cnt++;
}
out<<cnt;
return 0;
}