Cod sursa(job #1623182)
Utilizator | Data | 1 martie 2016 17:44:24 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#include <bitset>
#define INF 0x3f3f3f3f
using namespace std;
ifstream is("ciur.in");
ofstream os("ciur.out");
int n, m;
bitset<2000001> c;
int main()
{
is >> n;
m = 1;
for ( int i = 3; i <= n; i += 2 )
if ( !c[i] )
{
++m;
for ( int j = 2 * i; j <= n; j += i )
c[j] = 1;
}
os << m;
is.close();
os.close();
return 0;
}