Cod sursa(job #2367261)
Utilizator | Data | 5 martie 2019 09:50:04 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 70 |
Compilator | cpp-64 | Status | done |
Runda | pregatire_cls9_ojiii | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int oszto[2000000];
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
int n,db=0;
f>>n;
oszto[0]=oszto[1]=1;
for(int i=2;i*i<=n;i++){
if(oszto[i]==0){
for(int j=2;j<=n/i;j++)
oszto[i*j]=1;
}
}
for (int i=0;i<n;i++)
if (oszto[i]==0)
db++;
g<<db;
g.close();
return 0;
}