Pagini recente » Cod sursa (job #33545) | Cod sursa (job #1937157) | Cod sursa (job #1547742) | Cod sursa (job #836876) | Cod sursa (job #634618)
Cod sursa(job #634618)
#include<fstream>
#include<iostream>
using namespace std;
bool prim[2100100];
int n;
int ciur() {
int i,j,cont=1;
for(i=3;i<=n;i+=2)
if(!prim[i]) {
cont++;
for (j = i + i + i; j <= n; j += i << 1)
prim[j]=1;
}
return cont;
}
int main() {
long long clo=clock();
ifstream in("ciur.in");
in>>n;
in.close();
ofstream out("ciur.out");
out<<ciur()<<'\n';
out.close();
cout<<clock()-clo<<" ms";
return 0;
}