Pagini recente » Cod sursa (job #1713349) | Cod sursa (job #866279) | Cod sursa (job #2881237) | Cod sursa (job #1388594) | Cod sursa (job #2692800)
#include <fstream>
#include <bitset>
#define nmax 2000000
using namespace std;
ifstream cin("ciur.in");
ofstream cout("ciur.out");
bitset <nmax + 1> seive;
int main(){
int limit, countPrimeNumber = 1;
seive[0] = seive[1] = true;
cin >> limit;
for(int i = 4; i <= limit; i += 2){
seive[i] = true;
}
for(int i = 3; i <= limit; i += 2){
if(!seive[i]){
countPrimeNumber++;
for(int j = i * i; j <= limit; j += 2 * i){
seive[j] = true;
}
}
}
cout << countPrimeNumber;
return 0;
}