Cod sursa(job #2640010)
Utilizator | Data | 4 august 2020 17:46:34 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
#define MAX 5000005
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int n, cnt;
bitset < MAX > c;
int main(){
in>>n;
cnt = 1;
for(int i = 3; i * i <= n; i += 2)
for(int j = i * i; j <= n; j += 2 * i)
c[j] = 1;
for(int i = 3; i <= n; i += 2)
if(!c[i])
cnt++;
out<<cnt;
}