Cod sursa(job #2428696)
| Utilizator | Data | 6 iunie 2019 02:55:19 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <cmath>
#include <bitset>
#define Nmx 2000005;
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int n, i, j, x = 1;
bitset <Nmx> t;
int main()
{
in >> n;
t[0] = t[1] = 1;
for (i = 2; i <= int(sqrt(n)); i ++)
if (t[i] == 0)
for (j = 2; j <= n/i; j ++)
if (t[i*j] == 0){
t[i*j] = 1;
x ++;
}
out << n-x;
return 0;
}
