Cod sursa(job #2252103)
Utilizator | Data | 2 octombrie 2018 12:15:36 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | musai_must | Marime | 0.42 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bool CE[2000001];
int n,k;
void ciur()
{
for(int i=2;i<=sqrt(n);i++)
{
for(int j=i;j<=n;j++)
if(CE[i*j]==0)
CE[i*j]=1;
}
}
int main()
{
f>>n;
ciur();
for(int i=3;i<=n;i=i+2)
if(CE[i]==0)
k++;
g<<k+1;
return 0;
}