Cod sursa(job #1315854)
| Utilizator | Data | 13 ianuarie 2015 10:43:13 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <bitset>
using namespace std;
typedef long long int int64;
const int Nmax 2000005;
ifstream in("ciur.in");
ofstream out("ciur.out");
bitset<Nmax> v;
int64 ciur(int64 n){
for (int64 i = 3; i * i <= n; ++i)
if (!v[i])
for (int64 j = i * i; j <= n; j += i)
v[j] = 1;
for (int64 i = 1; i <= n; ++i)
if (!v[i]) ++total;
}
int main(){
int n;
in >> n;
out << ciur(n);
return 0;
}
