Cod sursa(job #2876491)
Utilizator | Data | 23 martie 2022 11:58:35 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <fstream>
#include <vector>
#include <queue>
using namespace std;
ifstream f ("ciur.in");
ofstream g ("ciur.out");
long long n,a[1001],x[1001],j,b,i,k;
int main()
{
f>>n;
for(i=2;i<=n;i++)
if(a[i]==0)
{k++;
for(j=i+i;j<=n;j=j+i)
a[j]=1;
}
g<<k;
}