Cod sursa(job #2377506)
| Utilizator | Data | 10 martie 2019 14:00:05 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
int n;
f>>n;
int a[n-2]={0};
int c=0,i,k;
for (i=2;i<=n;i++)
{
if (a[i-2]==0)
{
c++;
for (k=i-2;k<=n;k=k+i)
{
a[k]=1;
}
}
}
g<<c;
f.close();
g.close();
return 0;
}
