Cod sursa(job #2041936)
Utilizator | UNIBUCThrowTerror Spiromanii_Messi | Data | 17 octombrie 2017 21:28:40 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
using namespace std ;
ifstream fin ("ciur.in") ;
ofstream fout ("ciur.out") ;
const int MAX = 2e6 + 14 ;
bitset <MAX> viz ;
int main(int argc, char const *argv[])
{
int n ;
fin >> n ;
int sol = 0 ;
for (int i = 2 ; i <= n ; ++ i) {
if (viz [i]) continue ;
for (int j = i + i ; j <= n ; j += i) {
viz [j] = 1 ;
}
sol += 1 ;
}
fout << sol ;
return 0;
}